Copying Files Using rsync

rsync is a file transfer tool now included with Ubuntu. According to the rsync man page, it is a "faster, flexible replacement for rcp, the traditional remote copy application." We have already mentioned that rcp is not a secure method of transferring files.

A significant benefit of using rsync is that it speeds up file transfers by transferring only the differences between the two sites across a network link. rsync can copy links, devices, owners, groups, and permissions, and it can be told to exclude certain files. rsync can use ssh (via the command line or setting the rsync_rsh variable) and does not require root privileges. rsync has support for anonymous or authenticated rsync servers for use in mirroring.

The man page is extremely well-written and provides four excellent examples of how rsync can be used to transfer files matching a pattern, can recursively transfer files, and can be used locally (without a server).

The rsync command has some 62 options (not including short and long variants of the same option). A few particularly useful options are

-z Uses gzip compression.

-p Keeps partial files and reports on the progress of the transfer. —bwlimit=KBPs Sets a maximum bandwidth rsync might use.

--exclude-from=FiLE All excluded files listed in a separate file; pattern matching is enabled. -x Does not cross file system boundaries. -n Dry run for testing.

-l Copies symlinks, not the files themselves. -l Copies the file, not the symlink. -r Copies recursively. -v Verbose output.

The rsync utility can be run as a daemon to establish an rsync server, listening on TCP port 873 by default. The configuration of the server is handled by the contents of the /etc/rsyncd.conf file; the man page for rsyncd.conf provides the details. The daemon can be launched standalone or via inetd to suit your needs.

The rsync website provides an examples page showing examples of • Backing up to a central server with a seven-day increment

• Backing up to a spare disk

• Mirroring a CVS tree

• Automated backup at home over a modem

A time and bandwidth saving trick is to use rsync to only re-download that part of an ISO file that is incorrect, rather than downloading the entire 650 to 700MB of the file. First, you must locate an rsync server that is offering the .iso images you seek. An rsync server will provide modules, or directory trees as symbolic names. To determine if a server provides an rsync module, use the query:

rsync some.site.com::

If an rsync server is running on that site, you will see a list of available rsync modules. If we try

$ rsync ftp-linux.cc.gatech.edu:: GEORGIA TECH SOFTWARE LIBRARY

Unauthorized use is prohibited. Your access is being logged. If you run a publicly accessible mirror, and are interested in mirroring from us, please contact [email protected].

altlinux

mirror

of

ftp.

, altlinux.ru

arklinux

mirror

of

arklinux.org

asplinux

mirror

of

ftp

. asp-linux.com

debian

mirror

of

ftp

.debian.org

debian-cd

mirror

of

ftp

.debian.org

mandrake

mirror

of

ftp.

,mandrake.com

redhat

mirror

of

ftp

.redhat.com

<SNIP>

To use this rsync service, we would explore the redhat module to discover the file path to the .iso images using rsync -r and the module name to explore it recursively.

To use rsync to repair our defective .iso images, we point rsync at the "good" image and at our "bad" image like so:

sudo rsync -a -vvv —progress ftp-linux.cc.gatech.edu::\ redhat/linux/9/en/iso/i3 8 6/shrike-i3 8 6-disc1.iso\ ~/downloads/shrike-i386-disc1.iso rsync compares the two files and will download only the needed replacement parts for our local file much faster than downloading the entire image again.

Was this article helpful?

0 0

Post a comment