Backup on box.com from Linux (works at KTH)

by Martin Monperrus, Orestis Floros

Backup with rclone

rclone works well.

  rclone config (then choose "box.com")

Then,

 rclone authorize box
 # this opens a browser, select "Use Single Sign On (SSO)"

This check that you have a token in .config/rclone/rclone.conf

 [box]
 type = box
  {"access_token":"C7cTpR2bdF371NYPQ9cjQh0TKtVlLz8W", "token_type":"bearer", "refresh_token":"gZePzEGWRDOVJ9n2FZRllHdsy0lg6wKnnVi7u1jsLUC8IqqQAxrK3r3WqUVojqRI", "expiry":"2019-06-07T00:35:06.682138001+02:00"}

Finally, backup

  rclone ls box:
  rclone -v sync --one-file-system --exclude-from /home/martin/exclude-list-rsync.txt local:/home/martin box:backup-rclone

Warning: rclone purge does not permanently delete the files on box, see https://github.com/rclone/rclone/issues/3059

Backup with Borg

Borg is a deduplicating backup program. It organises your files in chunks and also supports encryption and compression. Whenever you create a new backup, only new chunks are stored, saving a significant amount of storage.

In combination with rclone, you just need to sync your borg repo with a Box folder. The benefits of this approach are that you get encryption and compression, rclone is faster because it has to copy significantly fewer files and through deduplication you have to transfer less data, making your daily backups faster. The downside is that you also need to keep a local copy of your backup repo.

Here is an example:

# Do once:
borg init --encryption=repokey /path/to/repo
# Do daily:
borg create --progress --stats --show-rc --exclude '/home/*/.cache' "/path/to/repo::$(date)" "$HOME"
rclone -v sync --one-file-system /path/to/repo 'box:backup-borg'

Backup with LFTP

  1. Set up your box.com password: If box.com is configured with SSO (the case for KTH), you must first create an external password, see Creating and using an external password for Enterprise Box for instructions.
  2. Save your login information. In order to automatically connect, the password must be stored in a file called .lftp/bookmarks. Here, foobar@kth.se is my login and pass123 is my password Box ftps://foobar@kth.se:pass123@ftp.box.com:990
  3. Create a lftp script backup.lftp (see below)
  4. Run the script lftp -f backup.lftp
set ftps:initial-prot ""
set ftp:ssl-force true
set ftp:ssl-protect-data true

# speed up the backup
set ftp:use-mode-z true
set ftp:mode-z-level 9
set mirror:parallel-directories true
# must be lower than 40, otherwise the error message is "Login rejected: Limit of 40 logins per user already reached"
set  mirror:parallel-transfer-count 39

# important if you're on a NAT network
set passive true

# "Box" refers to .lftp/bookmarks
open Box
# equivalent to "open ftps://ftp.box.com:990"

# box.com's FTP does not support symbolic links: "Access failed: 502 Command SITE not implemented for SYMLINK"
mirror --reverse --delete --no-perms --no-symlinks "/home/martin" backup

Acknowledgements

Using Box under Linux

Tagged as: