Created
July 10, 2016 22:00
-
-
Save peterkappus/a23b92d4517ab3483b535cb7295426e0 to your computer and use it in GitHub Desktop.
A backup script to backup various things to my USB Drive
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
#copy ~/Library/keychain | |
#for testing | |
rsync_flags = "avzn --delete" | |
#for real... | |
#--delete => delete files which don't exist in the source | |
rsync_flags = "avz --delete" | |
remote = "/Volumes/Thor/nemo_backup" | |
#backup apple keychain items | |
`mkdir -p #{remote}/Library/Keychains` | |
`rsync -#{rsync_flags} ~/Library/Keychains/ #{remote}/Library/Keychains` | |
#backup this script | |
`rsync -#{rsync_flags} ~/manual_backup.rb #{remote}/` | |
#various directories to backup | |
dirs = "Music Pictures Sites Dropbox Reference Desktop".split(' ') | |
#backup each one. | |
#NOTE: the trailing slash on the source prevents the directory from being recreated at the destination | |
dirs.each do |dir| | |
cmd = "rsync -#{rsync_flags} ~/#{dir} #{remote}" | |
puts cmd | |
puts `#{cmd}` | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment