cd /home/strebel
curl "https://raw.githubusercontent.com/andreafabrizi/Dropbox-Uploader/master/dropbox_uploader.sh" -o dropbox_uploader.sh
chmod 775 dropbox_uploader.sh
./dropbox_uploader.sh
``
To configure dropbox_uploader.sh, you'll need to create a Dropbox API key.
Last active
October 4, 2015 04:15
-
-
Save strebl/3d9e629eda6959516534 to your computer and use it in GitHub Desktop.
Simple Shell Backup to Drobox
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
TIME=`date +%Y%m%d` # Current date (format: yyymmdd) | |
DELDATE=`date --date="-30 day" +%Y%m%d` # Current date minus 30 days. (format: yyymmdd) | |
FILENAME=teamspeak-backup-$TIME.tar.gz # The filename of the backup. | |
SRCDIR=/home/strebel/teamspeak # Location of Important Data Directory (Source of backup). | |
DROPBOX_UPLOADER=/home/strebel/dropbox_uploader.sh # Dropbox Uploader Path | |
DROPBOX_UPLOADER_CONFIG=/home/strebel/.dropbox_uploader # Dropbox Uploader Config Path | |
# Tar directory | |
echo "Compressing \"$SRCDIR\" to \"$FILENAME\"..." | |
tar -cpzf -C /tmp/$FILENAME $SRCDIR . | |
# Upload the new file | |
$DROPBOX_UPLOADER -f $DROPBOX_UPLOADER_CONFIG upload /tmp/$FILENAME . | |
# Delete old backups | |
BACKUPS=$($DROPBOX_UPLOADER -f $DROPBOX_UPLOADER_CONFIG list | sed -n 's/.*\([0-9]\{8\}\)\.tar.*/\1/p') | |
for time in $BACKUPS; do | |
if (($time <= $DELDATE)) | |
then | |
echo "Deleting backup from date $time." | |
$DROPBOX_UPLOADER -f $DROPBOX_UPLOADER_CONFIG delete teamspeak-backup-$time.tar.gz | |
else | |
echo "Backup from date $time isn't old enought to delete." | |
fi | |
done | |
# Delete tar | |
rm /tmp/$FILENAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment