Abbey Workshop

Using rsync to Mirror Directories

The rsync utility can be used to mirror a directory locally or over a network. As the name implies, rsync synchronizes two directories. Key benefits of the utility include:

Command Basics and the slash

To copy a directory from one directory to another, they command line would be:

rsync -options --otherOptions sourceDir targetDir

Example 1: rsync -vaz ~/bk/ ~/test

This example copies the contents of the ~/bk directory to the test test directory.

Example 2: rsync -vaz ~/bk ~/test

This example creates a bk directory under the ~/test directory and recursively copies the contents of the ~/bk into this new directory. This is slighly different from the first example.

Command Line Options

A few command line options are listed in the previous example. Each of these options is described below.

Key rsync Options
Option Description
-v Turn on verbose mode
-a This turns on archive mode. Bascially this causes rsync to recurse the directory copying all the files and directories and perserving things like case, permissions, and ownership on the target. (Note: Ownership may not be preserved if you are not logged in as the root user.)
-z Turns on compression during the transfer. This option compresses the data as it is copied over the network.

Copying over ssh

To use ssh to copy the files over the network, just add the --rsh option to the command line. Simply specify the ssh command line as shown in the example. Also, to specify another machine as a target, precede the directory target with a host name and a colon.

Example 3: rsync -vaz --rsh="ssh -l username" ~/bk targetHost:~/test

After typing the command line, you will be prompted for your password. After entering the password, the command executes and your files are copied. You can also set the ssh command using the RSYNC_RSH environment variable. You can also avoid entering the ssh password if you use ssh keys.

The --exclude Option

This option allows you to exclude certain files and directories from the copy process. You can exclude by specific names or by using wildcards.

Example 4: rsync -vaz --exclude=log/ --exclude=*.xml ~/bk targetHost:~/test

In this example, the log directory is excluded from the copy as well as any file with a .xml extension.

The --delete Option

This option deletes any files that exist in your target directories but that do not exist in the source directory struction. Using this option truly keeps your files synchronized. However, use this option with caution. It can delete a lot of stuff on the target machine if you aren't careful.

For more information, see the following books

Google
  Web abbeyworkshop.com   

Copyright © Abbey Workshop 2006

Music Only Search
The Black MP3 Album
The MP3 Album Lyrics
Wprld Music Plus
Mp3 Songs Blog
Music Search Store
First Music Search
Mega MP3 Blog
E MP3 BLog
My MP3 Diary
Fast MP3 Finder
My Blog MP3
Mp3 Songs Mart
My MP3 Songs Album
Top Music Group
Mp3 Tune Records
Song Album Guide
Music DataDite
MP3 Buying Guide
Top MP3 Downloads
MP3 Tune Festival
FAST MP3 Downloads
MP3 Mart Online
Upper MP3
Premium MP3 Site
Music Data online
Fine MP3 Audio
Cheap Music Albums
Fine mp3 downloads
World MP3 Music Records
Mp3 Music Data Direct
The Fine Mp3
MP3 Files World
Home Music Store
DatMP3
Fat MP3 Audio
MP3 ZigZag
MP3 Songs Direct
MP3 Tune World
E MP3 Log
Boom MP3 Music
Speedy MP3
Top 20 MP3 music
Deep MP3 World
Deep MP3 Download
Best-20 MP3
Top Twenty MP3
Deep MP3
Big MP3 Guide
Deep MP3 Audio
Mp3 R.O.B.
MP3-Pop Online
Greate-20-MP3
MP3 Appear
3T-MP3