PDA

View Full Version : Rsync Help



thebookfreak58
25th March 2010, 06:32 PM
Hi All,

I'm looking to improve my backups for my MBP. At the moment, I have a RAID1 1.5TB Synology NAS box that is used as a file server, and there is client software on two Windows boxes, that automatically backup weekly.

For my Mac I manually SuperDuper my whole drive to a 320GB External HDD each saturday. (Sometimes I forget)!

I also backup important folders (Music, Documents and my Photography) every now and then to a separate 2.5in 60GB HDD.

What I'd like some help in, is to set up a rsync script to backup those important folders (Music, Documents and Photography) to a folder in a share on my Synology box. I'm guessing the script can be set to run automatically, or upon running it manually.

Any information that'd help (IP of NAS or name of share) and I'll provide!

TIA!

dangelovich
25th March 2010, 07:08 PM
A simple script should do the job... set it up to run from cron, and it'll be fine.
I haven't tested this, because I don't have a samba server handy, but the basic commands should be right.



#!/bin/bash

# Create the mount point
if [ ! -d /share ]; then
mkdir /share
fi

# Mount the share
mount_smbfs //username:password@192.168.0.1/sharename /share

# Sync files. --delete removes files from the destination that aren't on the source any more - thus ensuring a mirror copy.
rsync -axvE --delete /Users/username/Pictures/ /share/Pictures/
rsync -axvE --delete /Users/username/Documents/ /share/Documents/
rsync -axvE --delete /Users/username/Music/ /share/Music/
umount /share

thebookfreak58
25th March 2010, 07:18 PM
A simple script should do the job... set it up to run from cron, and it'll be fine.
I haven't tested this, because I don't have a samba server handy, but the basic commands should be right.



#!/bin/bash

# Create the mount point
if [ ! -d /share ]; then
mkdir /share
fi

# Mount the share
mount_smbfs //username:password@192.168.0.1/sharename /share

# Sync files. --delete removes files from the destination that aren't on the source any more - thus ensuring a mirror copy.
rsync -axvE --delete /Users/username/Pictures/ /share/Pictures/
rsync -axvE --delete /Users/username/Documents/ /share/Documents/
rsync -axvE --delete /Users/username/Music/ /share/Music/
umount /share


Thanks for that! I just found arRsync, so I'm running that for the first run, but will use your script once it's done.

Questions:
1. Will this erase the backup and copy the whole lot each time? Or will it only copy/delete enough to make them mirror?
2. Since my laptop isn't always at home, I'd rather run in manually, I just copy the code into a .sh file and run from Terminal?

Thanks!

dangelovich
25th March 2010, 07:26 PM
1. It doesn't initially delete anything. It will remove files that are no longer at the source, overwrite files which have changed since the last sync, and add new files. It doesn't remove anything unless it is missing from the source. The first sync will probably take a while. Subsequent syncs will be faster (although if there are many small files, the initial processing can take some time. Watch the output of those commands and you'll see whats going on...)
2. Yeah, make that a sh file, or a .command file if you want to be able to double-click it from Finder. You'll also need to set the permissions on it to allow executing (chmod 755 ~/Desktop/myscript.command)

thebookfreak58
26th March 2010, 09:25 AM
Hm do the resource forks cause it to trip up?

It's been stuck on this screen for about 15min. http://img87.imageshack.us/img87/3793/screenshot20100326at924.jpg

dotnet
26th March 2010, 09:49 AM
Since the target file system doesn't support resource forks you better drop the E switch from the rsync command line. That way you won't end up with all those ._ files.

Cheers
Steffen.