Duplicity incrementally backs
up files and directory by
encrypting tar-format volumes
with GnuPG and uploading
them to a remote (or local)
file server. Currently local,
ftp, ssh/scp, rsync, WebDAV,
WebDAVs, HSi and Amazon S3 backends
are available. Because
duplicity uses librsync, the incremental
archives are space efficient
and only record the parts of files
that have changed since the last backup. Currently duplicity
supports deleted files, full
Unix permissions, directories,
symbolic links, fifos, etc.,
but not hard links.
|
#Cent 6:
rpm -Uvh
http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm
#Cent 5:
rpm -Uvh
http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
|
yum --enablerepo=epel
install duplicity
|
Get the URL for the latest version here: http://duply.net/?title=Duply-downloads
download it to your server, extract it, and copy duply to /usr/local/bin/duply then chmod +x /usr/local/bin/duply
wget http://dev.justynshull.com/duply_1.5.5.1.tgz
tar xvzf duply_1.5.5.1.tgz
cp duply_1.5.5.1/duply /usr/local/bin/duply
chmod +x /usr/local/bin/duply
|
mkdir /etc/duply &&
chmod 700
/etc/duply
duply testvm1 create
|
This is what mine usually look like(without encryption) using rsync over ssh:
# egrep -v
'^#|^$' /etc/duply/testvm1/conf
GPG_KEY='disabled'
TARGET='rsync://backups.justynshull.com//home/testvm1/backups'
TARGET_USER='testvm1'
SOURCE='/'
MAX_AGE=3M
MAX_FULL_BACKUPS=3
MAX_FULLBKP_AGE=30D
VOLSIZE=3500
DUPL_PARAMS="$DUPL_PARAMS
--full-if-older-than $MAX_FULLBKP_AGE "
DUPL_PARAMS="$DUPL_PARAMS --volsize $VOLSIZE "
DUPL_PARAMS="$DUPL_PARAMS
--include=/etc \
--include=/home \
--include=/root \
--include=/var/www \
--include=/var/lib/mysql \
--include=/var/log \
--exclude=/** "
|
Duply/Duplicity supports using GPG to encrypt volumes before uploading them to the remote server, and the easiest way to enable encryption is by putting this in your conf:
#comment out
#GPG_KEY from earlier
#GPG_KEY='disabled'
GPG_PW='secret_password'
|
If you’re running mysql on the server, you should consider adding something similar to this to /etc/testvm1/pre, which gets run automatically by duply, to dump all databases before backing up the server.
#!/bin/sh
mkdir -pv
/root/db_backups
for db in
$(mysql -uroot
-e 'show
databases' -s --skip-column-names |
grep -v
'information_schema');
do
mysqldump -uroot
$db >
/root/db_backups/$db.sql;
sleep
10;
done
|
duply testvm1 backup
|
If all goes well(no errors), then you should be okay to set up a cronjob to run duply backup.
# crontab -l
30 3 * * * /usr/local/bin/duply
testvm1 backup
30 5 * * sun /usr/local/bin/duply testvm1 backup_verify_purge --force
|
If you use the above crontab, the 2nd line will run once a week, purging old backups from the remote server. If you’re worried about keeping too many backups, you might want to increase how often this runs and also decrease the options in the duply profile configuration.
Duply makes it easy to see what you’re currently backing up.
To see a list of backups stored on the remote server:
duply testvm1 status
|
duply testvm1 verify
|
duply testvm1 list 1D
|
It’s just as easy to restore complete or partial backups.
Restore the entire latest backup to /tmp/restore:
duply testvm1 restore /tmp/restore
|
duply testvm1 restore /tmp/restore
1W
|
duply testvm1 fetch home/justyns /tmp/restore
#When using
'fetch', make sure you leave off the leading slash.
|
duply testvm1 fetch home/justyns/plans_for_world_dom.txt
/home/justyns/plans_for_world_dom.txt 1M
|