24 · 01

Duplicity: simple, efficient and secure backup solution for Unix

Backuping data is a real problem. Investing 2 RAID 1 harddrives is a little expensive for a workstation. Duplicity is able to do incremental backups with the rsync algorithm. All backuped data are encrypted with gpg. All duplicity options are available on the official website. I wrote a small script for automate backup on my workstation. backup.sh:
#!/bin/sh
ROOT="/root/backup"
DISTANT="ssh://user@zaphod.eu//home/user"
PASSPHRASE="xxxxxxxxxxxx"
KEEP_ARCHIVE="2M" # 2 Months
FILELIST="files.lst"
export PASSPHRASE
duplicity       --include-globbing-filelist "${ROOT}/${FILELIST}" \
--exclude '**' \
--full-if-older-than "${KEEP_ARCHIVE}" / "${DISTANT}"
duplicity remove-older-than ${KEEP_ARCHIVE} ${DISTANT}
Then a small file list specifies what has to be backuped or not.
files.lst:
- /home/shad/p0rn
- /home/shad/tmp
+ /etc
+ /home/shad
According to duplicity documentation, a line beginning with a '+' specify a directory or a file to include and '-' for exclude. Be aware of list order.
It remains to add a cron entry for a weekly schedule:
0 0 * * 1 backup.sh | mail -s "Backup Report" root@zaphod.eu
Now your worksation is secured, you can restore any files to any date within the backup delay.