Diferencia entre revisiones de «Rdiff-backup»
De gacq wiki
(→The script) |
(→Simple automatic incremental daily backup using rdiff-backup) |
||
Línea 1: | Línea 1: | ||
= Simple automatic incremental daily backup using rdiff-backup = | = Simple automatic incremental daily backup using rdiff-backup = | ||
== The script == | == The script == | ||
− | Put the backup script on /srv/backups/rdiff-backups/$ | + | Put the backup script on /srv/backups/rdiff-backups/$SERVER_TO_BACKUP-rdiff-backup.sh |
<pre> | <pre> | ||
− | + | SERVER_TO_BACKUP=vtiger1.aiki-translations.com | |
rdiff-backup \ | rdiff-backup \ | ||
--print-statistics \ | --print-statistics \ | ||
− | --remote-schema "ssh -i /srv/backups/rdiff-backups/id_rsa-$ | + | --remote-schema "ssh -i /srv/backups/rdiff-backups/id_rsa-$SERVER_TO_BACKUP -C %s 'sudo /usr/bin/rdiff-backup --server --restrict-read-only /'" \ |
--preserve-numerical-ids \ | --preserve-numerical-ids \ | ||
--verbosity 4 \ | --verbosity 4 \ | ||
Línea 15: | Línea 15: | ||
--include /home \ | --include /home \ | ||
--exclude / \ | --exclude / \ | ||
− | backup@$ | + | backup@$SERVER_TO_BACKUP::/ $SERVER_TO_BACKUP |
rdiff-backup --force --remove-older-than 4W $HOSTNAME | rdiff-backup --force --remove-older-than 4W $HOSTNAME | ||
Línea 34: | Línea 34: | ||
;Run as root | ;Run as root | ||
<pre> | <pre> | ||
− | + | SERVER_TO_BACKUP=SERVER_TO_BACKUP | |
− | mkdir -p /srv/backups/rdiff-backups/$ | + | mkdir -p /srv/backups/rdiff-backups/$SERVER_TO_BACKUP |
apt-get install rdiff-backup python-xattr python-pylibacl | apt-get install rdiff-backup python-xattr python-pylibacl | ||
− | ssh-keygen -t rsa -N "" -f /srv/backups/rdiff-backups/id_rsa-$ | + | ssh-keygen -t rsa -N "" -f /srv/backups/rdiff-backups/id_rsa-$SERVER_TO_BACKUP |
− | cat /srv/backups/rdiff-backups/id_rsa-$ | + | cat /srv/backups/rdiff-backups/id_rsa-$SERVER_TO_BACKUP.pub | ssh root@$SERVER_TO_BACKUP 'cat - > /var/backups/.ssh/authorized_keys' |
− | chown root:root /srv/backups/rdiff-backups/id_rsa-$ | + | chown root:root /srv/backups/rdiff-backups/id_rsa-$SERVER_TO_BACKUP |
− | chmod 600 /srv/backups/rdiff-backups/id_rsa-$ | + | chmod 600 /srv/backups/rdiff-backups/id_rsa-$SERVER_TO_BACKUP |
− | chown root:root /srv/backups/rdiff-backups/$ | + | chown root:root /srv/backups/rdiff-backups/$SERVER_TO_BACKUP-rdiff-backup.sh |
− | chmod 750 /srv/backups/rdiff-backups/$ | + | chmod 750 /srv/backups/rdiff-backups/$SERVER_TO_BACKUP-rdiff-backup.sh |
− | echo "0 4 * * * root /srv/backups/rdiff-backups/$ | + | echo "0 4 * * * root /srv/backups/rdiff-backups/$SERVER_TO_BACKUP-rdiff-backup.sh" > /etc/cron.d/$SERVER_TO_BACKUP-rdiff-backup |
/etc/init.d/cron restart | /etc/init.d/cron restart | ||
</pre> | </pre> |
Revisión del 17:24 6 oct 2008
Contenido
Simple automatic incremental daily backup using rdiff-backup
The script
Put the backup script on /srv/backups/rdiff-backups/$SERVER_TO_BACKUP-rdiff-backup.sh
SERVER_TO_BACKUP=vtiger1.aiki-translations.com rdiff-backup \ --print-statistics \ --remote-schema "ssh -i /srv/backups/rdiff-backups/id_rsa-$SERVER_TO_BACKUP -C %s 'sudo /usr/bin/rdiff-backup --server --restrict-read-only /'" \ --preserve-numerical-ids \ --verbosity 4 \ --force \ --include /etc \ --include /home \ --exclude / \ backup@$SERVER_TO_BACKUP::/ $SERVER_TO_BACKUP rdiff-backup --force --remove-older-than 4W $HOSTNAME
On server to backup
apt-get install rdiff-backup python-xattr python-pylibacl sudo mkdir /var/backups/.ssh
add to /etc/sudoers
backup ALL = NOPASSWD: /usr/bin/rdiff-backup --server --restrict-read-only /
On backup server
- Run as root
SERVER_TO_BACKUP=SERVER_TO_BACKUP mkdir -p /srv/backups/rdiff-backups/$SERVER_TO_BACKUP apt-get install rdiff-backup python-xattr python-pylibacl ssh-keygen -t rsa -N "" -f /srv/backups/rdiff-backups/id_rsa-$SERVER_TO_BACKUP cat /srv/backups/rdiff-backups/id_rsa-$SERVER_TO_BACKUP.pub | ssh root@$SERVER_TO_BACKUP 'cat - > /var/backups/.ssh/authorized_keys' chown root:root /srv/backups/rdiff-backups/id_rsa-$SERVER_TO_BACKUP chmod 600 /srv/backups/rdiff-backups/id_rsa-$SERVER_TO_BACKUP chown root:root /srv/backups/rdiff-backups/$SERVER_TO_BACKUP-rdiff-backup.sh chmod 750 /srv/backups/rdiff-backups/$SERVER_TO_BACKUP-rdiff-backup.sh echo "0 4 * * * root /srv/backups/rdiff-backups/$SERVER_TO_BACKUP-rdiff-backup.sh" > /etc/cron.d/$SERVER_TO_BACKUP-rdiff-backup /etc/init.d/cron restart