-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Simple backup script
Andrea Fabrizi edited this page Apr 13, 2014
·
3 revisions
Following a simple script that can be used to schedule automatic backup to DropBox on your server or workstation.
The script:
#!/bin/bash
TMP_DIR="/tmp/"
DATE=$(date +"%d-%m-%Y_%H%M")
BKP_FILE="$TMP_DIR/MyBkp_$DATE.tar"
BKP_DIRS="/home/user /var/www /etc"
DROPBOX_UPLOADER=/path/to/dropbox_uploader.sh
tar cf "$BKP_FILE" $BKP_DIRS
gzip "$BKP_FILE"
$DROPBOX_UPLOADER -f /root/.dropbox_uploader upload "$BKP_FILE.gz" /
rm -fr "$BKP_FILE.gz"
Then add this line to your crontab:
00 00 * * * /path/to/backup.sh 2>&1 >> /var/log/backup.log
The script will be executed every night at midnight, and the logs will be stored in /var/log/backup.log.