Remote backups using ssh and dump

John Almberg jalmberg at
Fri Apr 4 18:25:13 UTC 2008

On Apr 4, 2008, at 1:59 PM, Paul Schmehl wrote:

> Has anyone done this?
> I'm presently using rsync over ssh, but I think dump would be  
> better if it will work.  I've been reading the man page, but I'm  
> wondering if anyone is doing this successfully and would like to  
> share their cmdline.

I do, but I'm not sure I'm doing it the optimal way. I'd love some  
feedback that might improve my simple script.

Basically, I back up each partition separately. I don't think it is  
possible to just dump from the root, although if it is possible, I'd  
like to know how.

This script assumes root can log into the backup server without a  
password. It 'rotates' the backups by including the day of the week  
in the file name, this gives me 7 days of complete backups.

I also take a snapshot of the home directory, in case I need to fetch  
one file from backup. These dumps are really intended for  
catastrophic failure (which, knock on wood, I've never actually needed.)

BTW, the primary and secondary servers both have dual nic cards. The  
backup server is directly connected to the primary server, using a  
crossover cable, so the nightly gigabyte transfer doesn't clog the  
office lan switch.

-- John

my $day_of_week = (localtime)[6];
my $file_prefix = '/backup/ON-'.$day_of_week.'-';
system('dump -0Laun -f - /tmp       | gzip -2 | ssh  
root at \'dd of='.$file_prefix.'tmp.gz\'');
system('dump -0Laun -f - /          | gzip -2 | ssh  
root at \'dd of='.$file_prefix.'root.gz\'');
system('dump -0Laun -f - /usr       | gzip -2 | ssh  
root at \'dd of='.$file_prefix.'usr.gz\'');
system('dump -0Laun -f - /usr/local | gzip -2 | ssh  
root at \'dd of='.$file_prefix.'usr-local.gz\'');
system('dump -0Laun -f - /var       | gzip -2 | ssh  
root at \'dd of='.$file_prefix.'var.gz\'');
system('dump -0Laun -f - /home      | gzip -2 | ssh  
root at \'dd of='.$file_prefix.'home.gz\'');

More information about the freebsd-questions mailing list