Success! (mostly)
With the help of
angelwatt I finally got rSync to sync some important files to an External HDD automatically.
This Method is not perfect, there is a slight issue I was unable to resolve, but it does work. Details at the bottom.
Step 1
Open Terminal.app, and type in (without quotes): "rsync --version"
If the version displayed is not 3.0.5 or greater, you should
download the latest release
I selected http download, then in the list I scrolled down to
http://rsync.samba.org/ftp/rsync/rsync-3.0.6.tar.gz
Double click the file to open it. If you are unable to open it, you probably need
Stuffit Expander
Once opened, and unpacked, you will see a folder with lots of files inside.
To Install
Find the "INSTALL" Document, and notice that it says:
Code:
To build and install rsync:
$ ./configure
$ make
# make install
In Terminal, type in "cd", space, then drag the rsync folder you unpacked from the desktop into terminal and hit ENTER.
Now Terminal will be working from that folder, you should notice the folder's path before the $ sign where you type:
Code:
~/Desktop/rsync-3.0.6 shaun$
Now that you're working from the folder, do exactly what the file said:
Type in. .
Hit enter, and it will begin doing stuff, once it finishes, type in:
It should do a bit more stuff automatically, and then finally:
sudo will give it the permissions it requires in order to finish.
Open Finder, and go to the hard drive. There is a hidden folder here called "usr". To access it, click "Go" in the finder menu, and select "go to folder". Then type in
/usr and press OK.
You will now see inside this hidden folder.
Here lies the problem I encountered:
rsync is automatically installed in OS X in the:
/usr/bin/ folder.
The Updated version I installed with the steps above went into:
/usr/local/bin/
No problem, simply access the hidden usr folder, navigate to
/usr/local/bin/rsync and drag the file into Terminal.
you should see something like:
Code:
shaun$ /usr/local/bin/rsync
You just have to type out the path to the new rsync rather than just typing "rsync".
----------------------------------------------------
To automate the process for fast backups at the click of a button, or on each login, do the following:
Open Script Editor
/Applications/Apple Script/Script Editor.app
Paste the following code:
Code:
on run
tell application "Finder"
activate
do shell script "/usr/local/bin/rsync --delete -avzX /path/to/main/folder/ /path/to/destination/folder/ "
end tell
end run
Everything in quotes is what the script enters as a command
/usr/local/bin/rsync is the command.
--delete -avzX are
arguments They tell the "rsync" command what to do. A full list of arguments can be found
Here
"a" "v" "z" "X" are case-sensitive, and are all separate, but can be placed together after the dash "-".
--delete is a single argument that must come first before the others.
-a = archive (a bunch of arguments in one)
-v = verbose (verbose argument determines how much information goes to the screen while the command is running. With rsync you'll see each file that is getting updated. Without verbose you would just be watching a blinking cursor while it runs with no idea what it's doing)
-z = compress (compresses files during transfer)
-X = preserve Extended attributes (custom icons, aliases, etc..)
--delete = Deletes extra files in the destination (anything at the destination folder that is NOT in the starting folder is deleted to maintain a perfect sync
Do not use the --delete command if you intend to work from the destination folder aswell, or you could create a file, and have it deleted because it does not exist in the starting folder
save the script as an "application" in the "save as..." menu. Drag it to the dock for quick access, or enter system preferences, accounts, 'startup items'. Add a new item to run on startup, find the application you just saved, and add it to the list.
On each login, the app will launch, which will simply run the command to sync the folders.
And that's about it. I set mine up to sync a "Files" folder where I keep all documents/photos, and also a separate one to sync my iTunes music folder to the external HDD. It copied documents, pictures, special .rsrc & .icns icon files, and also preserves the custom icons attached to folders and files -- that's what the "-X" command was for, and that's why I needed rsync 3.0.6 installed because 2.0 did not recognize the "-X" argument.
-----------------------------------------------------
-------------------------------------------------------
Credit goes to
angelwatt
Here is another message relating to the fact that the new rsync installs in another location to the normal one:
from angelwatt
I went through the update and saw it does install to a separate location. It doesn't want to overwrite the exiting one. You could move the new one to the old location an overwrite it, but don't have to.
In addition to typing the full path, you can also create an alias, which lets you setup a short command to call the full path. It just involves adding a line to a file (that may or may not currently exist).
- Open Terminal
- Type: pico ~/.profile
- It opens a file to edit and enter this line,
- alias rsync2="/usr/local/bin/rsync"
- Then hold ctrl and hit X to get out. It'll ask to save the file, hit Y, then enter.
- Next time you start up Terminal you can use the rsync2 command to call the new version.
That's just an alternative if you're wanting to do it. Since you'll be using the command in a script it won't really make a difference.
LINKS:
Introduction to UNIX
Commonly used UNIX Commands