Backup Dropbox

To set-up a server for backing up DropBox accounts.

Set-up your gpg keys (see Cloud Server).

Create a pillar file listing the name of the accounts you want to backup e.g. sites/dropbox.sls:

dropbox:
  accounts:
    - pat_hatherleigh_info
    - web_pkimber_net

Hint

Our standard for the names is to take the email address of the Dropbox account and replace @ and . with _ e.g. pat@hatherleigh.info becomes pat_hatherleigh_info.

Include this sls file into the top.sls file for your server e.g:

'dropbox':
  - global.gpg
  - global.users
  - sites.dropbox

Apply the salt states to your server. This will create folders, backup scripts, cron and supervisor tasks for each account e.g:

/home/web/repo/files/dropbox/pat_hatherleigh_info
/home/web/opt/backup_dropbox_pat_hatherleigh_info.sh
/etc/cron.d/dropbox
/etc/supervisor/conf.d/dropbox_pat_hatherleigh_info

Initialise

Each Dropbox account will need to be initialised. Log into your server:

sudo -i

Find the log file for the supervisor task for your account:

ls -l /var/log/supervisor/

Note

If the file is empty (0 bytes), then log into the supervisor console (supervisorctl) and check the status of the process. If you see this message, can't find command '/home/web/.dropbox-dist/dropboxd' then DropBox was probably installed after the supervisor script was created. Just re-start the process to resolve this issue.

Follow the file e.g:

tail -f /var/log/supervisor/dropbox_pat_hatherleigh_infok-stdout---supervisor-NI0cjP.log
# sample output
This computer isn't linked to any Dropbox account...
Please visit https://www.dropbox.com/cli_link_nonce?nonce=f123abc123abc123abc123abc123abc1 to link this device.

Open a private (or incognito session) in a browser . Log into the DropBox account you want to sync and paste in the URL.

The script will tell you that the account is linked e.g:

This computer is now linked to Dropbox. Welcome Pat

To check the sync, look in the following folder (update folder names as required):

sudo -i -u web
ls -l /home/web/repo/files/dropbox/pat_hatherleigh_info/Dropbox/

To initialise the backup run the backup script with the full argument e.g:

/home/web/opt/backup_dropbox_pat_hatherleigh_info.sh full

Restore

To restore a document or folder, follow the example commands in Duplicity.

Usage

Note

For the following, refer to your company Checklist and replace 123@tv-s009.rsync.net with your rsync.net Host address.

To check the rsync.net usage (by domain), create a script for in your ~/bin as follows. At your command prompt type the following:

gedit ~/bin/rsync-usage

Then type or paste the following 2 lines (Please note: the backslash before the asterisk is important:

#!/bin/bash
ssh 123@tv-s009.rsync.net du -sh \*

Save the file and close gedit. Then type the following at your command prompt:

chmod 755 ~/bin/rsync-usage

Now to get the analysis of usage on our rsync account, you can type:

rsync-usage

Stop dropbox running

If salt is used to configure dropbox on a server (“sites.dropbox” from the server config of top.sls), removing it from the salt configuration does remove it from the server.

To remove from the server log on the server and change to the superviser configuration directory

cd /etc/superviser/conf.d

The dropbox configuration file will be called

dropbox_<email address with ‘@’ and ‘.’ replaced with ‘_’>

for example if your dropbox login is web@hatherleigh.info the file will be called:

dropbox_web_hatherleigh_info

Delete this file using:

sudo rm dropbox_web_hatherleigh_info

Or comment the contents of the file by putting # at the beginning of each line using your favourite editor.

Then get the supervisor daemon to reread the configuration using:

supervisorctl reread

This will probably report:

dropbox_web_hatherleigh_info: disappeared

And then apply the configuration:

supervisorctl update

This will stop the processes respawning once stopped but will not stop existing processes.

Check the existing dropbox processes using the command:

ps -ef | grep dropbox | grep -v grep

Terminate these using your favourite process termination method e.g.:

pkill -f dropbox

Verify that app processes are terminated using the above process status command.