[oak perl] Remote backup script

M. Lewis cajun at cajuninc.com
Sat Apr 9 21:18:27 PDT 2005


I wrote this little script yesterday to solve a problem on a machine 
that I'm about to upgrade. The problem is, the machine is too old to 
understand rsync --from-file=FILE.

Nothing fancy, no error checking, run in middle of night a few times 
before actual upgrade.

I'm far too lazy to sit here and type in all of the scp commands each 
time. Hence, the little perl script.

Comments welcome.
--------------------------
#!/usr/bin/perl -w

# 4/8/05  written to backup files from remote client when rsync on
# the remote machine was too old to understand --files-from=FILE

# must be run as root in order to get all files!!!

my $host="host.client.com";
my $dest="./clientbackup";

@files=qw(/etc/aliases
           /etc/dpcpd.conf
           /etc/hosts
           /etc/hosts.allow
           /etc/hosts.deny
           /etc/passwd
           /etc/smb.conf
           /etc/smb.conf.rpmnew
           /etc/smbpasswd
           /etc/smbusers
           /etc/rc.d/rc.local
           /etc/rc.d/init.d/firewall
           /etc/sysconfig/network
           /etc/sysconfig/network-scripts/ifcfg-eth0
           /etc/sysconfig/network-scripts/ifcfg-eth1
           );

@dirs=qw( /home/users/cajun
           /home/users/craig
           /home/users/joanne
           /home/users/lrowell
           /home/users/swatty
           /home/users/wtheobald
           /var/spool/cron
           );

foreach $i (@files){
    print "Backing up $host:$i to $dest\n";
    `scp -p "$host:$i" "$dest"`;
# had to put in the sleep or else it bombs out the ssh server....
    sleep 10;
};


foreach $j (@dirs){
    print "Backing up $host:$j to $dest\n";
    `scp -pr "$host:$j" "$dest"`;
# had to put in the sleep or else it bombs out the ssh server....
    sleep 10;
};

-------------------------

-- 

   Everybody needs a little love sometime; stop hacking and fall in love!
  23:11:01 up 3 days,  7:47,  6 users,  load average: 0.20, 0.20, 0.13

   Linux Registered User #241685  http://counter.li.org


More information about the Oakland mailing list