This is my simple backup script. It keeps everything I don't already have backed up
in version control safe and sound from hardware failure. Not from me though -
if I delete a file accidentally, that file is really gone
(unless you act fast before the next backup runs!).
If I make a bad edit, that file is busted.
But I can live with that.
#!/usr/bin/env ruby
NAME = %x{ hostname }.strip
SSH_USER = "brad"
REMOTE_DIR = "/home/brad/Backups/#{ NAME }"
HOSTS = [ "clamps", "hubert.lucky-dip.net" ]
DIRS = [
"~/Library",
"~/Documents",
"~/Pictures"
]
EXCLUDES = [
"*Cache*",
"*NewsFire*",
"*Cookies*",
"*.log",
"HistoryIndex.ox*",
"*Virtual Machines*",
"*.resume",
"*.ipsw",
"*.dmg",
"*.corrupt"
]
HOSTS.each do |host|
DIRS.each do |dir|
puts "--------------------------------------------"
excludes = EXCLUDES.map { |e| "--exclude \"#{ e }\"" }.join(' ')
cmd = "rsync -av --delete --delete-excluded "
cmd += " --rsh=\"ssh -l #{ SSH_USER }\" "
cmd += " #{ dir } #{ host }:#{ REMOTE_DIR } #{ excludes }"
puts cmd
system(cmd)
end
end
0 22 * * * /Users/brad/projects/scripts/backup.rb