Backups / Dump etc

Mike Tancsa mike at
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
dump to an NFS mount.

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

you want to back up

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

set the passwd to whatever you want

On the webserver,
su root
ssh-keygen -d
scp ~root/.ssh/
webserver1 at
ssh webserver1 at

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/

#!/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

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

on the web server, something like the following crontab
4 4 * * 0 /root/ 0
4 4 * * 1 /root/ 1
4 4 * * 3 /root/ 2
4 4 * * 4 /root/ 3
4 4 * * 5 /root/ 4
4 4 * * 6 /root/ 5
4 4 * * 7 /root/ 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

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
and run disklable and create the slices to match your new drive

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

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...


More information about the freebsd-questions mailing list