Backups / Dump etc

Mike Tancsa mike at sentex.net
Fri Jan 14 17:22:32 PST 2005


On Fri, 14 Jan 2005 13:00:26 -0400, in sentex.lists.freebsd.questions
you wrote:
>
>I know that dump is the bees-knees for backing up, so I'm looking for
>any pre-made scripts for doing scheduled incremental backups with
>dump.. or articles about dump etc..

Yes, dump and restore are what you should look at. It probably will
meet your needs.

>
>I've also been told that dump lacks network support and tho you can
>use -f and ssh, it's very slow.

Dump and pipe it through ssh via ssh key'd authentication
or
dump to an NFS mount.


This is off the top of my head, so test first 


e.g.
you want to back up webserver1.example.org
to backupserver1.example.org


On the backup server, 
pw useradd webserver1 -m
su webserver1
cd
ssh-keygen -d
passwd webserver1

set the passwd to whatever you want

On the webserver,
su root
ssh-keygen -d
scp ~root/.ssh/id_dsa.pub
webserver1 at example.org:~webserver1/.ssh/authorized_keys2
ssh webserver1 at backupserver1.example.org

You should be able to get in without a password now and you can * out
the passwd for webserver1


On the webserver, create the script below in /root/dump.sh

#!/bin/sh -

#this example script will dump the / partition to the backup server

if [ -z $1 ] ; then
        echo ""
        echo "Usage: $0 <backup level>"
        echo "       See 'man dump' for more information."
        echo ""
        exit 255
fi

DUMP_LEVEL=$1
/sbin/dump -${DUMP_LEVEL}anuf - / | /usr/bin/gzip -9c | /usr/bin/ssh
-2 -c 3des webserver1 at backupserver1.example.org dd
of=~webserver1/dump-root-${DUMP_LEVEL}.gz
/sbin/dump -${DUMP_LEVEL}anuf - /usr | /usr/bin/gzip -9c |
/usr/bin/ssh -2 -c 3des webserver1 at backupserver1.example.org dd
of=~webserver1/dump-usr-${DUMP_LEVEL}.gz
/sbin/dump -${DUMP_LEVEL}anuf - //sbin/dump -${DUMP_LEVEL}anuf - /usr
| /usr/bin/gzip -9c | /usr/bin/ssh -2 -c 3des
webserver1 at backupserver1.example.org dd
of=~webserver1/dump-usr-${DUMP_LEVEL}.gz | /usr/bin/gzip -9c |
/usr/bin/ssh -2 -c 3des webserver1 at backupserver1.example.org dd
of=~webserver1/dump-var-${DUMP_LEVEL}.gz



on the web server, something like the following crontab
4 4 * * 0 /root/dump.sh 0
4 4 * * 1 /root/dump.sh 1
4 4 * * 3 /root/dump.sh 2
4 4 * * 4 /root/dump.sh 3
4 4 * * 5 /root/dump.sh 4
4 4 * * 6 /root/dump.sh 5
4 4 * * 7 /root/dump.sh 6


WIll do a differential dump each day across the network with a level 0
dump (a full dump) once per week on Sunday morning.

To do a full restore (assuming those are all your partitions) on the
backup server, pop the new drive in.  Firewire attached drives work
quite well under FreeBSD

Assuming these directories do not exists,

mkdir /tmp/root
mkdir /tmp/usr
mkdir /tmp/var

/stand/sysinstall
fdisk the new drive and make sure you make it bootable.
exit out (I think this is to work around a bug that I occasionally run
into)
/stand/sysinstall
and run disklable and create the slices to match your new drive



Create the mount points on something like /tmp/root, /tmp/usr and
/tmp/var

And newfs it....


cd /tmp/root
zcat ~webuser1/dump-root-0.gz | restore -rf - 
zcat ~webuser1/dump-root-1.gz | restore -rf - 
...
zcat ~webuser1/dump-root-6.gz | restore -rf - 

and so on...

	---Mike


More information about the freebsd-questions mailing list