Hetzner - DokuWiki
Duplicity Script
Dieses HowTo ist fuer duplicity 0.4.11 .
Nach der erfolgreichen installation von duplicity, wollen wir 2 monate lang einen taeglichen backup haben. Dazu, jeden ersten des monats soll ein voller backup erstellt werden.
In meinem fall, hab ich ein separates backup fuer /etc /home /srv [ was bei mir die meisten daten hat], und / .
So, das geht ganz einfach:
Erstellen wir mal ein file was /usr/sbin/duplicity.sh heisst. Sie muessen dan noch die informationen wie das ftp kennwort, den gpg passphrase den sie benutzen wollen, den ftp benutzername und den host, austauschen. Da kommt folgendes rein:
BEGIN OF /usr/sbin/duplicity.sh
#!/bin/sh # # Script created on 17-6-2008 # # This script was created to make Duplicity backups. # Full backups are made on the 1st day of each month. # Then incremental backups are made on the other days. # # Loading the day of the month in a variable. date=`date +%d` # Setting the pass phrase to encrypt the backup files. Will use symmetrical keys in this case. PASSPHRASE='yoursecretgpgpassphrase' export PASSPHRASE # Setting the password for the FTP account that the # backup files will be transferred to. FTP_PASSWORD='yourftppass' export FTP_PASSWORD # Check to see if we're at the first of the month. # If we are on the 1st day of the month, then run # a full backup. If not, then run an incremental # backup. if [ $date = 01 ] then duplicity remove-older-than 2M -v5 ftp://user@host/srv >>/var/log/duplicity/srv.log duplicity remove-older-than 2M -v5 ftp://user@host/etc >>/var/log/duplicity/etc.log duplicity remove-older-than 2M -v5 ftp://user@host/home >>/var/log/duplicity/home.log duplicity remove-older-than 2M -v5 ftp://user@host/system >>/var/log/duplicity/system.log duplicity full -v5 /srv ftp://user@host/srv >>/var/log/duplicity/srv.log duplicity full -v5 /etc ftp://user@host/etc >>/var/log/duplicity/etc.log duplicity full -v5 /home ftp://user@host/home >>/var/log/duplicity/home.log duplicity full -v5 --exclude-filelist /etc/duplicityfilelist.conf / ftp://user@host/system >>/var/log/duplicity/system.log else duplicity remove-older-than 2M -v5 ftp://user@host/srv >>/var/log/duplicity/srv.log duplicity remove-older-than 2M -v5 ftp://user@host/etc >>/var/log/duplicity/etc.log duplicity remove-older-than 2M -v5 ftp://user@host/home >>/var/log/duplicity/home.log duplicity remove-older-than 2M -v5 ftp://user@host/system >>/var/log/duplicity/system.log duplicity incremental -v5 /srv ftp://user@host/srv >>/var/log/duplicity/srv.log duplicity incremental -v5 /etc ftp://user@host/etc >>/var/log/duplicity/etc.log duplicity incremental -v5 /home ftp://user@host/home >>/var/log/duplicity/home.log duplicity incremental -v5 --exclude-filelist /etc/duplicityfilelist.conf / ftp://user@host/system >>/var/log/duplicity/system.log fi # Check http://www.nongnu.org/duplicity/duplicity.1.html # for all the options available for Duplicity. # Unsetting the confidential variables so they are # gone for sure. unset PASSPHRASE unset FTP_PASSWORD exit 0
END OF /usr/sbin/duplicity.sh
In diesem file haben wir eine fileliste zitiert. Diese muss auch erstellt werden: Erstellen wir also ein file der /etc/duplicityfilelist.conf heisst.
Da kommt folgendes rein:
BEGIN OF /etc/duplicityfilelist.conf
- /dev - /proc - /sys - /tmp - /etc - /home - /srv - /var/cache
END OF /etc/duplicityfilelist.conf
Zuletzt stellen wir ein cronjob auf. Erstellen wir ein file der /etc/cron.d/duplicity heisst , mit dem folgendem inhalt:
BEGIN OF /etc/cron.d/duplicity
0 0 * * * /usr/sbin/duplicity.sh >/dev/null 2>&1
END OF /etc/cron.d/duplicity
So, das war's .
Viel spass, und gutes backup.
Danke an sethx aus dem Hetznerforum.
--Deltaflyer 20:41, 17. Jun 2008 (CEST)