Skip to content

Instantly share code, notes, and snippets.

@jrh-spg
Last active March 11, 2019 21:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrh-spg/db351fecac002dbb01cd3de306da4bd1 to your computer and use it in GitHub Desktop.
Save jrh-spg/db351fecac002dbb01cd3de306da4bd1 to your computer and use it in GitHub Desktop.
A simple duplicity backup script
#!/bin/bash
ulimit -n 10000
PIDFILE=/var/run/backup.pid
LOGFILE=/var/log/backup.log
if [ -f "$PIDFILE" ]; then
RUNPID=`cat $PIDFILE`
if ps -p $RUNPID; then
echo "Backups are already running..."
exit 1
else
echo "Backup pid found but the process is dead. Cleaning up..."
rm -f $PIDFILE
fi
else
echo "No backup process detected"
fi
echo $$ > $PIDFILE
test -x $(which duplicity) || exit 0
. /root/.passphrase
export PASSPHRASE
$(which duplicity) --encrypt-key E4C7DC7A628F94E2 --exclude /tmp --exclude /proc --exclude /dev --exclude /sys --exclude /backup --exclude /run --exclude /home/jharris/Videos / file:///backup/duplicity |/usr/bin/tee $LOGFILE
echo -n "Backups completed at: "
date
rm -f $PIDFILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment