Synchronizing Files with rsync
Code listing 5.9. Installing rsync through FreeBSD's ports system.
bsd# cd /usr/ports/net/rsync bsd# make install clean rsync comes with an included version of
popt. To build rsync with devel/popt instead,
hit Ctrl-C now and define WITH_POPT_PORT ===> Vulnerability check disabled, database
not found >> rsync-2.6.2.tar.gz doesn't seem to exist
in /usr/ports/dist/image/library/english/13776_. >> Attempting to fetch from
http://rsync.samba.org/ftp/rsync/. . . .
The rsync program is used for synchronizing files and directories between systems, and it can be used as a backup tool.But again, it's an insecure method because none of the rsync TRaffic is encrypted in any way, so you should only allow rsync connections between trusted computers.Since rsync is so insecure, we'll look at ways of making your system share file-system resources "the right way" in the next chapter.Note that you can secure rsync transfers by combining it with SSH.To install rsync (FreeBSD) By default, rsync isn't installed under FreeBSD, so we'll have to install it from the ports collection (Code Listing 5.9).
1. | cd /usr/ports/net/rsyncChange to the rsync directory in the ports system. | 2. | make install cleanDownload, build, and install rsync, then clean up the build directory. |
To install rsync (Cygwin) Like FreeBSD, rsync isn't installed by default (or by the inetutils package) on Cygwin, so we'll have to install it.
1. | Launch the Cygwin setup.exe, then click the Next button until you get to the package-selection screen. | 2. | Expand the Net category by clicking the plus sign beside it. | 3. | Click the circle-arrow icon for the rsync package, so that the Skip entry changes to a version number (Figure 5.13).Figure 5.13. Installing rsync with the Cygwin Setup application. [View full size image] | 4. | Click Next in the Cygwin Setup window to install the new package and any updates to packages you already have installed.Code listing 5.10. Activating rsync support on Fedora Core.
[chrish@dhcppc1 ~]$ cd /etc/xinetd.d [chrish@dhcppc1 xinetd.d]$ sudo vi rsync . . . [chrish@dhcppc1 xinetd.d]$ ps ax | egrep
xinetd 2032 ? Ss 0:00 xinetd -stayalive
-pidfile /var/run/xinetd.pid 20162 pts/2 S+ 0:00 egrep xinetd [chrish@dhcppc1 xinetd.d]$ sudo kill HUP
2032
| 5. | Click Finish in the Cygwin Setup window to exit the Cygwin Setup program. |
To enable rsync access (xinetd) Fedora Core and Mac OS X use the xinetd super-server to control rsync access.
1. | cd /etc/xinetd.dChange to the xinetd configuration directory.Code listing 5.11. Adding rsync support to xinetd on Mac OS X.
service rsync { disable = no socket_type = stream wait = no user = root server = /usr/bin/rsync server_args = --daemon log_on_failure += USERID }
| 2. | If you're using Fedora Core (Code Listing 5.10), edit the rsync file using your favorite editor.If you're using Mac OS X, you need to create the rsync file (Code Listing 5.11) using your favorite text editor. | 3. | Change the disable=yes line to disable=no, and then save the file. | 4. | kill -HUP xinetd_pidRestart xinetd by sending it a HUP signal. |
To enable rsync access (inetd) FreeBSD and Cygwin use the inetd super-server to control rsync access.
1. | cd /etcChange to the inetd configuration directory. | 2. | Use your favorite text editor to edit the inetd.conf file. | 3. | Remove the # character(s) at the start of the rsync line, then save the file. | 4. | kill -HUP inetd_pidRestart inetd by sending it a HUP signal. |
To use rsync to back up a directory One use for rsync is to copy directories between systems, to duplicate them or just to make a backup.- rsync -PpogrtlHcz source destinationUse rsync to copy the source to the destination.The source is specified as a local directory path.The destination is specified as hostname_or_IP:directory_path.The options are -P (show progress and keep partial files), -p (preserve file permissions), -o (preserve ownership), -g (preserve group), -r (recursive; copy directories and their contents), -t (preserve times), -l (preserve symbolic links), -H (preserve hard links), -c (checksum the files to make sure they're transferred properly), and -z (use compression while transferring files).
 |