Home documents FreeBSD Adventures with dump and restore
Adventures with dump and restore Print E-mail
Written by Peter Boosten   
Monday, 24 July 2006 22:04

Some time ago the harddisk of my FreeBSD server Ra (I like Egypt: my other servers are called: Osiris, Amon, Ankh, Ramses, Nefertiti, Muth) crashed. Since I didn't make any backups everything seemed lost.

A tool called Acronis True Image let me dump the whole contents of the disk as an image (20 Gigs) to a network drive, so that part was save, but the harddisk had died.

So I bought a new harddrive, 250 GB, and dumped the contents of the image back to the new harddisk with Acronis, but somehow Acronis cannot handle ufs properly.

So I had a harddisk, 250GB, and only used 20GB of it.

Last weekend, I changed that all...

After reading a good discussion on comp.unix.bsd.freebsd.misc about dump, the Unix-way of making backups, I decided to do the big thing:

repartition my harddisk. I used dump/restore, since it would backup and restore everything: files, directories, links, devices & permissions.

For this purpose I downloaded a live FreeBSD CD, called Frenzy, which contains all the tools necessary to perform the job. I booted Ra from this CD and it mounted my harddisk read-only.

The first thing to do was dumping all filesystems to another machine over the network. This was the easy part. The command I used looked something like this:

# dump -0f - /dev/ad0s1f | ssh ankh dd of=ra-usr

This dumped the filesystem /usr (level zero which means complete) to a file called ra-usr on server ankh. Since the disk was mounted underneath the live CD, I cound not use "/usr" to backup the filesystem, since it would have to be in /etc/fstab, so I used the device name "/dev/ad0s1f". I could have gzipped the whole part to save some space on ankh, but since ra only contained about 12 Gigs in total, I decided to dump without gzip. In any case the dumps will be faster without gzip. If you want to gzip, the command would have looked like this:

# dump -0f - /dev/ad0s1f | gzip -c | ssh ankh dd of=ra-usr.gz

I repeated this for all mounts.

Somehow Frenzy did not let me fdisk and bsdlabel the harddisk the way I wanted, so I used the FreeBSD installation CD to do this job for me. So I sliced and partitioned (or was it the other way around) and had it install a minimal FreeBSD, which I was going to remove anyway.

After the installation completed I rebooted the machine again from the Frenzy CD, but now I had it mount the harddisk read-write. In each mount (which was mounted as /mnt/ad0s1a.ufs, /mnt/ad0s1d.ufs, etc) I removed all files. I did this because I noticed that restore did not overwrite existing files, or at least existing links, or at least I thought it did).

Restoring was also easy:

# ssh ankh dd if=ra-usr | restore -vrf -

I issued this command in the directory where /usr of the harddisk was mounted, so in /mnt/ad0s1f.ufs. Again, if you had gzipped the files, you would have to unzip the file in the stream:

# ssh ankh dd if=ra-usr.gz | gunzip -c | restore -vrf -

After having performed this for all filesystems, I rebooted Ra, and I had lots of free space: everything worked like charm. Cool

Last Updated ( Tuesday, 20 May 2008 19:07 )
 
Please register or login to add your comments to this article.