Created
January 2, 2012 15:33
-
-
Save pkazmierczak/1551124 to your computer and use it in GitHub Desktop.
Simple script for automatic backup using duplicity
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
#!/bin/bash | |
BACKUP_SCRIPT=${0##*/} | |
DUPLICITY="/usr/bin/duplicity" | |
DATE="/bin/date +%R-%d-%m-%y" | |
BACKUP_COMMAND="$DUPLICITY --exclude=/media/backups --exclude=/home/piotr/.cache --exclude=/home/piotr/.thumbnails --exclude=/home/piotr/.gvfs --exclude=/home/piotr/.xsession-errors --exclude=/home/piotr/.recently-used.xbel --exclude=/home/piotr/.recent-applications.xbel --exclude=/home/piotr/.Private --exclude=/tmp --exclude=/proc --exclude=/sys --exclude=/home/piotr/.local/share/Trash --exclude=/home/piotr/muzzik --exclude=/home/piotr/filmy --exclude=/home/piotr/.beagle --exclude=/home/piotr/.opera --exclude=/home/piotr/.thumbnails --exclude=/home/piotr/.VirtualBox --exclude=/home/piotr/.cache --exclude=/home/piotr/downloads --include=/home/piotr --exclude=** --no-encryption / file:///media/backups --volsize=250 --archive-dir=/home/piotr/.cache/deja-dup" | |
# Sanity checks | |
if test -z "$BASH" ; then | |
printf "$DATE \n$BACKUP_SCRIPT:$LINENO: please run this script with the BASH shell\n" >&2 | |
exit 192 | |
fi | |
if test ! -x "$DUPLICITY" ; then | |
printf "$DATE \n$BACKUP_SCRIPT:$LINENO: the command $DUPLICITY is not available - aborting\n" >&2 | |
exit 192 | |
fi | |
# Create an incremental backup if the portable drive is connected | |
if test -d /media/backups ; then | |
printf "\n\n\n\n\n`$DATE` \nBacking up!\n-------------------------------------------------\n" | |
$BACKUP_COMMAND | |
else | |
printf "`$DATE` \n$BACKUP_SCRIPT:$LINENO: portable drive not connected - aborting\n\n" >&2 | |
exit 192 | |
fi | |
# Cleanup | |
printf "`$DATE` Files backed up successfully\n-------------------------------------------------\n" | |
exit 0 # all is well |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment