OS X Easy Rsync Media Backup
I have a nice 350GB firewire drive hooked up to my mac mini HTPC. Unfortunately it fills up very fast and occasionally I’d like to copy files from it to a larger drive, then delete the old files making space available.
Copying everything at once is not efficient, I really just want to copy over only what is new, Rsync is the perfect solution for this.
Below is a simple bash script that uses Rsync. It copies only new files from my source drive to my backup drive. I run this manually whenever I want to free up some space. After it completes, I can delete whatever I want from my source drive.
#!/bin/sh # Source Directory BACKDIR="/Volumes/ministack/Media/" # Destination Directory. DESTDIR="/Volumes/bacukp-dive/" # Excludes EXCLUDE="--exclude Downloads/" # To Debug #OPTS="-n -vv -u -a --stats --progress" # To Backup OPTS="-v -u -a --stats --progress" rsync $OPTS $EXCLUDE $BACKDIR $DESTDIR
BACKDIR is the source directory I am copying from, DESTDIR is the destination. I exclude a single directory, in this case downloads but you can exclude as many files or directories as you need. Just remember you have to have one –exclude=foo pair for each exlcude. If your doing something complex you can store this info in a file. Google –exclude-from for the details . if you need to. If your backing up a HTPC setup like mine, it’s likely your organized in a manner that makes this easy.
You can un-comment the first opts line to debug the script, it will run through and show you changes.
Here are the options I use:
Debug
-n dry run, do not actually copy anything
-vv verbose, two v’s show what is skipped and copied
-u skip files that are new or have newer date on destination
-a archive, use recursion and preserve everything
–stats show me statistics about what you are doing
–progress show me progress of file transfer
Real Transfer
-v verbose, one V show me just what you copy
-u skip files that are new or have newer date on destination
-a archive, use recursion and preserve everything
–stats show me statistics about what you are doing
–progress show me progress of file transfer
Recent Comments