#! /usr/bin/perl #danrsync - a script to sync home directories #Copyright (C) 2005 Daniel Brewer #This program is free software; you can redistribute it and/or #modify it under the terms of the GNU General Public License #as published by the Free Software Foundation; either version 2 #of the License, or (at your option) any later version. #This program is distributed in the hope that it will be useful, #but WITHOUT ANY WARRANTY; without even the implied warranty of #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #GNU General Public License for more details. #http://www.gnu.org/copyleft/gpl.html $Home="/Users/daniel/"; @dirs=("bin","Applications","Desktop","Documents","Games",".gnupg","Library/Application Support/AddressBook"); @files=("Library/Mail/LSMMap*"); @exclude=("MLdonkey*","ISOs","MRes","*Poster*","Virtual PC*","*MAME*","*NotLaptop*"); $rsyncopts="--eahfs --rsync-path=\"/usr/local/bin/rsync\" --progress --delete -avzpe ssh"; $remoteurl="www.example.com"; $exclcount=$#exclude+1; for($i=0;$i<$exclcount;$i++) { $excludestring .="--exclude \"$exclude[$i]\" "; } print "EXCLUDES: ".join(" ",@exclude)."\n"; $dircount=$#dirs+1; for($i=0;$i<$dircount;$i++) { $command = "rsync $rsyncopts $remoteurl:\'\"$Home$dirs[$i]/\"\' \"$Home$dirs[$i]/\""; $command .=" ".$excludestring; print "----$dirs[$i]----\n"; # print "$command\n"; system($command); } $filecount=$#files+1; for($i=0;$i<$filecount;$i++) { $base=substr($files[$i],0,rindex($files[$i],"/")); $command = "rsync $rsyncopts $remoteurl:\"$Home$files[$i]\" \"$Home$base/\""; $command .=" ".$excludestring; print "----$files[$i]----\n"; # print "$command\n"; system($command); } system(calsync); exit 1;