Our new Indie Games subforum is now open for business in G&T. Go and check it out, you might land a code for a free game. If you're developing an indie game and want to post about it, follow these directions. If you don't, he'll break your legs! Hahaha! Seriously though.
Our rules have been updated and given their own forum. Go and look at them! They are nice, and there may be new ones that you didn't know about! Hooray for rules! Hooray for The System! Hooray for Conforming!

rsync, keeping two folders in sync

Shazkar ShadowstormShazkar Shadowstorm Registered User regular
edited April 2010 in Help / Advice Forum
hi

simple question

i run os x

i have a folder on one external hard drive
i would like it to be sync'd to another external hard drive, so in case one dies it survives

what is the easiest way to do this? how does rsync work?

Shazkar Shadowstorm on
| Steam & XBL: Shazkar | 3DS: 3110-5421-3843 | SS Wishlists |

Posts

  • admanbadmanb the bored genie Seattle, WARegistered User regular
    edited April 2010
    You'll want to setup a cron job or other automation of a shell script. The basic command is just rsync <folder a> <folder b> but you'll probably want to do -raz --delete (recursive, duh; archive, which copies permissions and such; compress, which reduces the transfer size; and --delete makes sure that any files you delete in the source are deleted in the destination.

    twitter, github, resume/portfolio, if you like to play or host boardgames online, check out handtracker
  • LewishamLewisham Registered User regular
    edited April 2010
    Any reason why you can't use Time Machine for the job? That way it'll have the folder versioned too.

  • EchoEcho staring is caring Super Moderator, Moderator mod
    edited April 2010
    Can Time Machine do individual folders then? I've only ever seen entire volume versioning.

    Anyway, you want Folder Actions. Right click folder -> More -> Folder Actions. You'll probably have to make the script yourself though, or find one somewhere.

    It'll run automatically when the folder changes, no need to wait for cron to kick in and run rsync.

    edit: on some further googling, it appears that Folder Actions only trigger when files are created/deleted, not modified.

  • admanbadmanb the bored genie Seattle, WARegistered User regular
    edited April 2010
    Time Machine just does exclusions, so it's designed to be a complete system backup (minus anything you don't particularly care for) that you can restore to.

    Annoyed me when I realized I wouldn't be able to use it to keep my docs and stuff backed up to my external HD. 'course, that died months ago and I can't afford to replace it, so I suppose it worked out.

    twitter, github, resume/portfolio, if you like to play or host boardgames online, check out handtracker
  • EchoEcho staring is caring Super Moderator, Moderator mod
    edited April 2010
    It's not really what the OP asked for, but I keep the important stuff in Dropbox (disclaimer: that's a referral link, but you get both me and yourself an extra 250 megs of storage through it), which syncs it on two different computers as well as online, with built-in versioning.

  • Shazkar ShadowstormShazkar Shadowstorm Registered User regular
    edited April 2010
    yeah, i use time machine for my computer's hard drive, this is between two external hard drives, none of this data is on my actual computer, i just want it to be redundant (lotta music and stuff i care about)

    sorry for my ignorance, any tutorial or something about writing a cron script? im mildly familiar with shell scripting but not a ton

    edit:
    Echo wrote: »
    It's not really what the OP asked for, but I keep the important stuff in Dropbox (disclaimer: that's a referral link, but you get both me and yourself an extra 250 megs of storage through it), which syncs it on two different computers as well as online, with built-in versioning.

    yeah, i have dropbox dude, but this is a 90 GB folder i'm talking about anywho

    | Steam & XBL: Shazkar | 3DS: 3110-5421-3843 | SS Wishlists |
  • EchoEcho staring is caring Super Moderator, Moderator mod
    edited April 2010
    Assuming standard Unix structure: poke at /etc/crontab.

    */5 * * * * /home/user/foo.pl

    That's the format. This runs every 5 minutes. Here's the syntax. Very easy.

  • Shazkar ShadowstormShazkar Shadowstorm Registered User regular
    edited April 2010
    how do i get the path for my folder anyway? the location is /Volumes/External Drive/folder name

    and then the other one would be /Volumes/External Drive 2/folder name

    err i am sorry i am so noob

    | Steam & XBL: Shazkar | 3DS: 3110-5421-3843 | SS Wishlists |
  • admanbadmanb the bored genie Seattle, WARegistered User regular
    edited April 2010
    What do you mean? The main thing you have to do is backslash-escape the spaces. So the first one would become

    /Volumes/External\ Drive/folder\ name

    twitter, github, resume/portfolio, if you like to play or host boardgames online, check out handtracker
  • Shazkar ShadowstormShazkar Shadowstorm Registered User regular
    edited April 2010
    but what i mean is how do you get to the very root, because ~ would just get me to
    /Users/myusername/

    and i need something in

    /Volumes

    | Steam & XBL: Shazkar | 3DS: 3110-5421-3843 | SS Wishlists |
  • LewishamLewisham Registered User regular
    edited April 2010
    No-one has told you to use a tilde, just specify the paths as you have been writing them out.

    You are being very confusing :)

  • admanbadmanb the bored genie Seattle, WARegistered User regular
    edited April 2010
    but what i mean is how do you get to the very root, because ~ would just get me to
    /Users/myusername/

    and i need something in

    /Volumes

    ~/ is just an alias for /Users/<your user>

    / is root.

    twitter, github, resume/portfolio, if you like to play or host boardgames online, check out handtracker
  • Shazkar ShadowstormShazkar Shadowstorm Registered User regular
    edited April 2010
    ah got it

    | Steam & XBL: Shazkar | 3DS: 3110-5421-3843 | SS Wishlists |
Sign In or Register to comment.