For quick local operations, the basic syntax is:
rsync -av /path/to/source/ /path/to/destination
The "a" option specifies "archive" mode, which preserves permissions, "v" gives more feedback.
Adding a trailing slash to "source" avoids creation of a "source" sub-dir in "destination".
In the above described rescue operation I first mounted my file server using cifs.
rsync is best for directories, not individual files. To copy a single file, use scp:
scp /path/to/sourcefile username@remote-macine:/path/to/destination
or the other way:
scp username@remote-macine:/path/to/sourcefile /path/to/destination
My desktop is a little non-standard:
http://forum.vectorlinux.com/index.php?topic=4564.0 I use my central file server a lot. Big files go over the network mountpoints to the server, and scripts sync my home dir with a copy that resides on a server drive.
This example illustrates how I use rsync to back up my home dir:
#!/bin/sh
# Backs up home dir to server. Runs every hour from crontab
rsync -auz -e "ssh -i /home/username/.ssh/username-rsync-key" --exclude-from /home/username/scripts/exclude --delete /home/username/ 192.168.1.X:/home/username
- This archives all files with permissions intact (a), updates newer files (u), uses compression (z),
- connects using ssh and a key without a password * (see below),
- excludes mount points that map to the server, using a simple text file:
Music
Storage
- deletes extraneous files on server.
Another script shuts the machine down:
#!/bin/sh
# Opens a terminal, runs backup, then shuts down
konsole -e rsync -auz -e "ssh -i /home/username/.ssh/username-rsync-key" --exclude-from /home/username/scripts/exclude --delete /home/username/ 192.168.1.X:/home/username
sudo /sbin/shutdown -h now
Adding the "konsole -e" gives me a terminal window so I can see the progress.
* For automated network operations, using ssh without first mounting the network resources, you first need to configure your machines for access using password-less public/private key pairs. I relied heavily upon this guide:
http://troy.jdmz.net/rsync/index.htmlFor backup through the internet I implemented the restrictions script, but not for my local network.