Diferencia entre revisiones de «Rdiff-backup»

De gacq wiki
Saltar a: navegación, buscar
(Backup etch from lenny)
 
(No se muestran 8 ediciones intermedias del mismo usuario)
Línea 1: Línea 1:
 
= Simple automatic incremental daily backup using rdiff-backup =
 
= Simple automatic incremental daily backup using rdiff-backup =
== The script ==
+
== On server to backup ==
Put the backup script on /srv/backups/rdiff-backups/$HOSTNAME-rdiff-backup.sh
+
<pre>
 +
apt-get install rdiff-backup python-xattr python-pylibacl sudo
 +
mkdir /var/backups/.ssh
 +
</pre>
  
 +
add to /etc/sudoers
 
<pre>
 
<pre>
HOSTNAME=vtiger1.aiki-translations.com
+
backup ALL = NOPASSWD: /usr/bin/rdiff-backup --server --restrict-read-only /
 +
</pre>
 +
 
 +
== On backup server ==
 +
;The script
 +
Put the backup script on /srv/backups/rdiff-backups/$SERVER_TO_BACKUP-rdiff-backup.sh
 +
 
 +
<pre>
 +
SERVER_TO_BACKUP=hostname_here
  
 
rdiff-backup \
 
rdiff-backup \
 
  --print-statistics \
 
  --print-statistics \
  --remote-schema "ssh -i /srv/backups/rdiff-backups/id_rsa-$HOSTNAME -C %s 'sudo /usr/bin/rdiff-backup --server --restrict-read-only /'" \
+
  --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 27:
 
  --include /home \
 
  --include /home \
 
  --exclude / \
 
  --exclude / \
  backup@$HOSTNAME::/ $HOSTNAME
+
  backup@$SERVER_TO_BACKUP::/ /srv/backups/rdiff-backups/$SERVER_TO_BACKUP
</pre>
 
  
== On server to backup ==
+
rdiff-backup --force --remove-older-than 4W /srv/backups/rdiff-backups/$SERVER_TO_BACKUP
<pre>
 
apt-get install rdiff-backup python-xattr python-pylibacl sudo
 
mkdir /var/backups/.ssh
 
</pre>
 
 
 
add to /etc/sudoers
 
<pre>
 
backup ALL = NOPASSWD: /usr/bin/rdiff-backup --server --restrict-read-only /
 
 
</pre>
 
</pre>
  
== On backup server ==
 
 
;Run as root
 
;Run as root
 
<pre>
 
<pre>
HOSTNAME=SERVER_TO_BACKUP
+
SERVER_TO_BACKUP=SERVER_TO_BACKUP
  
mkdir -p /srv/backups/rdiff-backups/$HOSTNAME
+
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-$HOSTNAME
+
ssh-keygen -t rsa -N "" -f /srv/backups/rdiff-backups/id_rsa-$SERVER_TO_BACKUP
cat /srv/backups/rdiff-backups/id_rsa-$HOSTNAME.pub | ssh root@$HOSTNAME 'cat - > /var/backups/.ssh/authorized_keys'
+
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-$HOSTNAME
+
chown root:root /srv/backups/rdiff-backups/id_rsa-$SERVER_TO_BACKUP
chmod 600 /srv/backups/rdiff-backups/id_rsa-$HOSTNAME
+
chmod 600 /srv/backups/rdiff-backups/id_rsa-$SERVER_TO_BACKUP
chown root:root /srv/backups/rdiff-backups/$HOSTNAME-rdiff-backup.sh
+
chown root:root /srv/backups/rdiff-backups/$SERVER_TO_BACKUP-rdiff-backup.sh
chmod 750 /srv/backups/rdiff-backups/$HOSTNAME-rdiff-backup.sh
+
chmod 750 /srv/backups/rdiff-backups/$SERVER_TO_BACKUP-rdiff-backup.sh
  
echo "0 4 * * * root /srv/backups/rdiff-backups/$HOSTNAME-rdiff-backup.sh" > /etc/cron.d/$HOSTNAME-rdiff-backup
+
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>
 +
 +
= Backup etch from lenny =
 +
Due to incompatible rdiff-backup version to backup Etch server using rdiff-backup on lenny you need to install a backported version on Etch server, add to /etc/apt/sources.list
 +
<pre><nowiki>
 +
deb http://www.backports.org/debian/ etch-backports main contrib non-free
 +
</nowiki></pre>
 +
 +
and run
 +
<pre><nowiki>
 +
apt-get install debian-backports-keyring
 +
apt-get update
 +
apt-get -t etch-backports install rdiff-backup
 +
</nowiki></pre>

Revisión actual del 23:43 24 jun 2009

Simple automatic incremental daily backup using rdiff-backup

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

The script

Put the backup script on /srv/backups/rdiff-backups/$SERVER_TO_BACKUP-rdiff-backup.sh

SERVER_TO_BACKUP=hostname_here

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::/ /srv/backups/rdiff-backups/$SERVER_TO_BACKUP

rdiff-backup --force --remove-older-than 4W /srv/backups/rdiff-backups/$SERVER_TO_BACKUP
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

Backup etch from lenny

Due to incompatible rdiff-backup version to backup Etch server using rdiff-backup on lenny you need to install a backported version on Etch server, add to /etc/apt/sources.list

deb http://www.backports.org/debian/ etch-backports main contrib non-free

and run

apt-get install debian-backports-keyring
apt-get update
apt-get -t etch-backports install rdiff-backup