[oak perl] Remote backup script

George Woolley george at metaart.org
Sat Apr 9 21:49:16 PDT 2005


Mike,
Thanks for posting this
and for exemplifying the Perl virtue of laziness.
George

On Saturday 09 April 2005 9:18 pm, M. Lewis wrote:
> 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;
> };
>
> -------------------------



More information about the Oakland mailing list