Backup To Other Computers
| |
Consider the situation of a collection of Debian boxes with no backup
facilities as such, but there is an accessible machine with a proper
backup regime. Access to the backed up machine is via ssh.
The backup can be performed using a backup script which you
create in /etc/cron.daily so that it will be executed each
day (by default, 6:25am). The contents of the script are:
#!/bin/sh
#
# Script for /etc/cron.daily
#
LOGFILE="/root/BACKUP.log"
RSYNC="/usr/bin/rsync"
DEST="[email protected]:backup/$(/bin/hostname)"
OPTS="--rsh=ssh --cvs-exclude --archive --compress "
OPTS=${OPTS}"--delete --delete-excluded --verbose"
INCFILE="/etc/backup.include"
echo "===================================================" >> ${LOGFILE}
date >> ${LOGFILE}
echo "$RSYNC $OPTS --include-from ${INCFILE} / ${DEST}" >> ${LOGFILE}
$RSYNC ${TESTING} $OPTS --include-from ${INCFILE} / ${DEST} >> ${LOGFILE}
date >> ${LOGFILE}
echo "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" >> ${LOGFILE}
|
The file /etc/backup.include might contain:
#
# Identify specific file types to exclude
#
- *.mp3
- *.rpm
- *.deb
- *.wav
- *.avi
- *.mov
- *.temp
- *.tmp
- *.cdr
#
# Exclude paths that contain
#
- .thumbnails
- .xvpics
- cache
- skins
- thumbnails
#
# Now specify specific trees to back up
#
+ /etc
+ /home
+ /root
+ /usr/local
+ /var/mail
+ /var/backups
#
# And exclude everything else
#
- /*
|
Since this is using ssh (OpenSSH, ssh protocol 2) and it is a cron job
(i.e., you can not supply a password or passphrase), create a ssh
public key for adding to kayon@caravan's authorized keys file:
modena# ssh-keygen -t dsa -N ""
Generating public/private dsa key pair.
Enter file in which to save the key (/root/.ssh/id_dsa):
Your identification has been saved in /root/.ssh/id_dsa.
Your public key has been saved in /root/.ssh/id_dsa.pub.
The key fingerprint is:
ce:b3:e5:82:ab:72:3d:50:2e:96:65:e0:15:a3:4e:de root@velox
modena# scp .ssh/id_dsa.pub [email protected]:.ssh/authorized_keys.n
modena# ssh kayon@caravan
caravan$ cd .ssh
caravan$ cat authorized_keys.n >> authorized_keys
caravan$ rm authorized_keys.n
caravan$ exit
|
Then the ssh connections will go straight through to
kayon@caravan without the need to supply a password (or
passphrase).
Copyright © 1995-2006 [email protected]
|