Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antoine-briand/5c37651320b35f23433b3c107528c4aa to your computer and use it in GitHub Desktop.
Save antoine-briand/5c37651320b35f23433b3c107528c4aa to your computer and use it in GitHub Desktop.
Backup dropbox business accounts using rclone
: '
This script helps me to backup Dropbox business accounts. Requires rclone to be installed on your machine (https://rclone.org/downloads/).
You must create a dropbox application (https://www.dropbox.com/developers/apps) with all READ scopes.
Then configure your rclone using rclone config
1) Choose dropbox
2) Set your remote name
3) On client_id, paste the value you have for "App key" on your Dropbox app (in settings)
4) On client_secret, paste the value you have for "App secret" on your Dropbox app (in settings)
5) Edit advanced config and set a value to the impersonate parameter (your admin account email e.g)
6) Do not edit other advanced config
7) On servers do not use auto config (n). On workstation use auto config. Either way, you must
Once rclone is configured, check if you can access dropbox business users by running :
rclone --dropbox-impersonate "oneofyourdropboxuser@email.com" lsd "remoteName":
To use the following script, simply create a .sh file and grant execution rights (chmod u+x myscript.sh).
Then run the script and do not forget to pass one of your user email adress as parameter.
Eg
./myscript.sh "myuser@email.com"
'
USER_EMAIL=$1
USER_BACKUP_PATH="./backed_up_data/$USER_EMAIL"
LOGS_PATH="log_$USER_EMAIL.txt"
echo "Backuping user $USER_EMAIL" >> ./$LOGS_PATH
mkdir -p $USER_BACKUP_PATH
rclone --log-file=./$LOGS_PATH --log-level=INFO --dropbox-impersonate "$USER_EMAIL" copy "dropbox": $USER_BACKUP_PATH/
echo "Backup of user $USER_EMAIL finished" >> ./$LOGS_PATH
@antoine-briand
Copy link
Author

To run the script for all users :

  1. Create a users.txt file with one user e-mail address per line
  2. Install gnuparallel (sudo apt install parallel)
  3. Run parallel -a users.txt ./do_backup.sh

It will copy your users dropbox data in parallel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment