Oreilly O really
James McDonald
james
Mon Nov 1 17:17:02 PST 2004
I presume most of us look to this list or google when we have admin
questions. However I have found that for myself the good old fashioned
paper book is sometimes the best way to soak up information.
One thing that has been annoying me is my lack of backup strategy so
when I saw a section in an Oreilly book "Linux Server Hacks - 100
Industrial-Strength Tips & Tools" on backup. I bought it... 20minutes
after getting it home I had ssh public key authentication working and a
rough script for network backup going.
What I did follows.
Firstly I had to enable public key login by running the following on the
source box as root
ssh-keygen -t rsa
and then copying the resulting public key to the target box, again as root
scp .ssh/id_rsa.pub target_server:.ssh/authorized_keys2
Once the public key is installed you can test it by simply sshing to the
box as root
ssh servername
To get backup going I made up this script very rudimentary....
I could have chosen to make one large remote tar ball but I chose to
split it up into
functional tars
#!/bin/sh
# filename: /home/jamesm/bin/backup
# things to backup
# mail
# apache config
# website
# home drive
# svn db
REMOTE_DIR=/mnt/hde1/backup
MYMAIL=/home/vpopmail/domains/jmcd.dyndns.org/jamesm/Maildir
tar -czvf - $MYMAIL | ssh mx1 "cat > $REMOTE_DIR/amd-jamesm-mail.tar.gz"
APACHE_CONFIG="/etc/httpd/access \
/etc/httpd/conf \
/etc/httpd/conf.d"
tar -czvf - $APACHE_CONFIG | ssh mx1 "cat > $REMOTE_DIR/amd-apache.tar.gz"
SVN=/opt/subversion
tar -czvf - $SVN | ssh mx1 "cat > $REMOTE_DIR/amd-svn.tar.gz"
MYHOME="/home/jamesm/Docs \
/home/jamesm/.ssh \
# /home/jamesm/mp3 \ probably not needed to backup mp3 or oggs every day
# /home/jamesm/ogg \
/home/jamesm/bin"
tar -czvf - $MYHOME | ssh mx1 "cat > $REMOTE_DIR/amd-myhome.tar.gz"
MYWEB=/var/www/html
tar -czvf - $MYWEB | ssh mx1 "cat > $REMOTE_DIR/amd-web.tar.gz"
you can run the above manually but it's probably easier to put it in
root's crontab
then all that is left is to run as root
crontab -e
and add a line to get it to backup every day at 2:05 am to call the script
05 2 * * * /home/jamesm/bin/backup
More information about the Linux-users
mailing list