[OpenBSDsupport]

Backup with dd and gzip.


Here is how to make a compressed partition archive over another hard disk Let's suppose our system is on wd0a and we just added a new disk wd1.

We use gzip to compress our file. This is a bit "bad style" overriding the default one but since we can reduce our backup from 1.6GB to 74MB (out of the box install), it's worth doing that trick :)

I've seen we can backup on another machine a similar way, just we have to ssh it (so make ldd on your installed ssh and do the same thing as for gzip) so it's really nice idea.


1. BACKUP
---------
With boot disk or type "bsd.rd" at boot prompt (if you kept it at
installation process)

# make our new hard disk (wd1) visible
cd /dev
chmod 777 MAKEDEV
./MAKEDEV wd1

# format it and create wd1a partition
fdisk -i wd1
disklabel -E wd1
newfs wd1a

# mount it
mount /dev/wd1a /mnt

# here we use our installed gzip to be able to compress
# we safe it on our backup hard disk, version numbers may
# change depending your openbsd version
mount /dev/wd0a /mnt2
cp /mnt2/usr/bin/gzip /mnt
cp /mnt2/usr/lib/libz.so.4.1 /mnt
cp /mnt2/usr/lib/libc.so.38.2 /mnt
cp /mnt2/usr/libexec/ld.so /mnt
umount /mnt2

# we replace the ramdisk gzip
rm -f /usr/bin/gzip
ln -s /mnt/gzip /usr/bin/gzip
ln -s /mnt /usr/lib
ln -s /mnt /usr/libexec

# finally, the backup with dd and gzip
dd if=/dev/wd0a | gzip -9 > /mnt/backup.gz

# here is the way without gzip, if u're mad
# dd if=/dev/wd0a of=/mnt/backup

2. RESTORE
----------
With boot disk or type "bsd.rd" at boot prompt

# make our new hard disk (wd1) visible
cd /dev
chmod 777 MAKEDEV
./MAKEDEV wd1

# mount it
mount /dev/wd1a /mnt

# format main hard disk
newfs wd0a

# restore backup
gunzip /mnt/backup.gz - | dd of=/dev/wd0a

# if archive not gzipped
# dd if=/mnt/backup of=/dev/wd0a