back up files onto dropbox
All machine, which includes Hard Disks, are to break some day. Let’s back up your precious content onto dropbox with encrypted on regular basis.
create backup directory in dropbox.
$ mkdir ~/Dropbox/backup
Prepare backup script kicked by cron on regular interval. Create directory where backup script resides:
$ mkdir ~/Documents/cron
Deploy following backup script under cron directory:
#!/usr/bin/env bash
# we use day of week as file name
LANG=C
NAME=`date "+%A"`
# please specify password for encryption in case that you encrypt backup file
PASSWD=xxxxxx
# we create backup file under temporary directory on local host
# so as to avoid latency
TEMP=/tmp
BACKUP_DIR=~/Dropbox/backup
cd ~/Documents
if true
then
find . -exec zip -P $PASSWD $TEMP/$NAME.zip {} \; 1>/dev/null 2>&1
else
find . -exec zip $TEMP/$NAME.zip {} \; 1>/dev/null 2>&1
fi
mv $TEMP/$NAME.zip $BACKUP_DIR
Please be noted that you have to add execution permission for this script. And test it if it works or not.
$ bash -xv backup.sh
Register cron job to start script on regular basis by “crontab -e”. With following example, backup script is executed every one hour at *:00.
0 * * * * ~/Documents/cron/backup.sh
On ubuntu, cron activity is recorded in /var/log/syslog. Monitor syslog if cron works as expected.