File:  [Local Repository] / sludge_scripts / backup.pl
Revision 1.2: download - view: text, annotated - select for diffs
Thu Jun 23 13:32:48 2011 UTC (13 years, 6 months ago) by nick
Branches: MAIN
CVS tags: HEAD
Fixed stupid mistakes.

#!/usr/bin/perl -w

use strict;
use Data::Dumper;

my $VERSION	= q/$Id: backup.pl,v 1.2 2011/06/23 13:32:48 nick Exp $/;
my $REMOTE	= "nick\@demandred.dyndns.org";
my $OPTIONS	= "-avxz\ -e\ ssh\ --delete";
my $RSYNC	= "/usr/bin/rsync";
my $LOGDIR	= $ARGV[0] || "/home/backup/logs";
my $DATE	= `date +%Y%m%d`;
my $BACKUP_DIR	= "/home/backup/backups";

my %DIRS = (
		demandred => [
			"/home/nick/database-backup.dump.gz",
			"/home/nick/database-backup.dump.yesterday.gz",
			"/home/nick/DroidBackups",
			"/home/cvs",
			"/home/nick/bbs",
			"/home/nick/notes",
			"/home/httpd",
			"/home/nick/Documents",
			"/home/nick/mail",
			"/home/nick/mail-backup",
		],
		winshare => [
			"/home/winshare/Documents",
			"/home/winshare/Pictures",
			"/home/winshare/Receipts",
			"/home/winshare/Shared\\ Docs",
			"/home/winshare/Backgrounds",
		],
		lanfear => [
			"/home/backup/systems/lanfear/home/nick/Documents",
			"/home/backup/systems/lanfear/home/nick/Receipts",
			"/home/backup/systems/lanfear/home/nick/Nick\\'s\\ Pictures",
			"/home/backup/systems/lanfear/home/nick/projects",
		 	"/home/backup/systems/lanfear/home/nick/notes",
		],
);

foreach my $backup ( keys %DIRS ) 
{
	foreach my $dir ( @{ $DIRS{$backup} } ) 
	{
		my $dest    = $BACKUP_DIR . "/" . $backup;
		my $command = "/usr/bin/rsync $OPTIONS \"$REMOTE:$dir\" $dest";
		print "Backing up $REMOTE:$dir to $dest\n$command\n";
		system( "mkdir -p $dest" );
		system( $command );
	}
}

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>