Camera Icon

Got an event that needs shooting?  I've covered multiple events for marathon-photos.com and can capture the scenes & emotions that make your event unique.

Some samples of my own work are at Digital Formula on Flickr.

Wand Icon

Do you or your business need a website but you're unsure where to start?  Get in touch now and we'll get it sorted.

I focus on usable functionality & can setup smaller sites using Wordpress within hours of the order being placed.  Magic!

Globe Icon

So, you've already got a website but need help managing it?  I can help you.

Don't worry about knowing every single detail.  I'll find out the most important stuff and work with you to reach your goal, not someone else's.

said on twitter: LOL spammers really do bank on the ignorance of their targets huh? A file with a .jpg.exe extension ... really? http://t.co/0TgobjQc

 
Short URL
Warning: This article is older than 180 days and may contain inaccurate information.  Please use the information below at your own risk.

Using rsync to synchronise folders

Synchronising is important

I keep most of my primary files on my iMac. Needless to say, this would be a pretty dumb move if I kept them there, and there only. However, I'm a paranoid freak when it comes to data, having lost 7 years worth of work in 1 go a few years back - I'm not letting that happen again. I use an Apple Time Capsule and Apple Time Machine for my primary backups and it's saved me once or twice already.

Why?

Anyway, because I also have a Macbook Pro, that means I'm sometimes working where my iMac isn't. I needed a solution to synchronise a specific set of folders on my iMac and my Western Digital portable USB drive. There are a ton of ways to do this but because I'm a geek I chose to use the command line (Terminal, in OS X) and write a small script. I'm using rsync for this - here's the script, should you need something like it yourself.

The Script

#!/bin/bash

# sync the files
rsync ~/Data/Solutions /Volumes/Backup --recursive --verbose --delete --progress --human-readable --exclude="tmp*"

# unmount the external drive
sudo diskutil unmount /Volumes/Backup

What does it do?

Simple! The script script above does the following.

  • Synchronises all files in the sub-folder Data/Solutions in my home folder onto my USB drive (called 'Backup'). All files matching the file pattern tmp* are skipped.
  • Ejects the USB drive when finished.
  • All sub-folders are included.
  • Files that exist in the destination but not in the source are deleted.
  • Progress of each file is displayed as it is copied.
  • All output is in human-readable format ... because I'm human.

The eject part prompts for my password before ejecting because the diskutil unmount command is a privileged operation and requires elevated rights before it will be allowed,

Simple, but useful. :)

» Tags: osx, linux, rsync, synchronise
DigitalFormula is an experiment in HTML5 and CSS3 design by Chris Rasmussen, an amateur/casual designer based in Melbourne, Australia. -37.813611 144.963056