Backing up using rsync

Discussion in 'Mac Programming' started by Dan A, Dec 2, 2012.

  1. macrumors newbie

    Joined:
    Dec 2, 2012
    #1
    Hi, I was wanting to create like a batch file for Apple Mac for rsync but not sure how you do this.


    I just want the file to sit on my desktop and click it every time to make a backup.


    These are the commands I wish to use.


    rsync -a -v /Users/administrator/Pictures /Volumes/Photos\ Disk\ 1
    rsync -a -v /Users/administrator/Pictures /Volumes/Photos\ Disk\ 2

    Also I am using the -a rather than -r as it preserves the time modified stamp, whereas -r will switch it to the time it was transferred to my knowledge.

    With the -a option if my computer died and I had to reimage would I still be able to access everything off the external HDD that is being used as the backup?


    Any assistance would be great, i've been googling but havent really come up with much.

    Thanks
    Dan
     
  2. macrumors 68040

    Joined:
    Feb 2, 2008
    #2
    All you would need to do to execute those lines is to save them to a file with the addition of a shebang (#!) and the interpreter you wish to use.

    Code:
    #!/bin/bash
    
    rsync -a -v /Users/administrator/Pictures /Volumes/Photos\ Disk\ 1
    rsync -a -v /Users/administrator/Pictures /Volumes/Photos\ Disk\ 2
    
    Copy paste that into a text editor and save it as say, "Backup Photos" to your desktop. Open up the Terminal and enter: chmod ugo+x ~/desktop/backup\ photos and you're done.

    The -a flag is a combination of many options including -r, the reason that time is preserved is the -t flag. You can read all about rsync in the manual in terminal just type: man rsync
     
  3. thread starter macrumors newbie

    Joined:
    Dec 2, 2012
    #3
    Thanks mate, all good now, just one question I still have a query on, If I am using the -a option as it copies all the permissions across, if my HDD fails for some reason and I need to reimage, will I be able to access the files off the backed copy on the external HDD

     
  4. macrumors 68040

    Joined:
    Feb 2, 2008
    #4
    The permissions will be preserved so it should not be an issue as far as I can tell. The -a (short for archive) is pretty much made for different backup scenarios, there are a lot of stuff written on rsync for backups that may be worth looking into if you are concerned about it's reliability.
     
  5. macrumors newbie

    Joined:
    Sep 15, 2012
    #5
    Thanks for the nice tips. It could be good enough for getting your valuable and memorable pics and data backup using resync.
     

Share This Page