\begin{exe} {Using rsync for Backup}

   \begin{enumerate}
      \item
      Using \textbf{rsync}, we will again create a complete
      copy of \filelink{/usr/include} in your backup
      directory:
      \begin{cmd}
$ rm -rf include
$ rsync -av /usr/include .
      \end{cmd}
      \begin{response}
sending incremental file list
include/
include/FlexLexer.h
include/_G_config.h
include/a.out.h
include/aio.h
.....
      \end{response}
      \item
      Let's run the command a second time and see if it
      does anything:
      \begin{cmd}
$ rsync -av /usr/include .
      \end{cmd}
      \begin{response}
sending incremental file list

sent 127398 bytes  received 188 bytes  255172.00 bytes/sec
total size is 41239979  speedup is 323.23
      \end{response}
      \item
      One confusing thing about \textbf{rsync} is you might
      have expected the right command to be:
      \begin{cmd}
$ rsync -av /usr/include include
      \end{cmd}
      \begin{response}
sending incremental file list
...
      \end{response}
      However, if you do this, you'll find it actually
      creates a new directory, \filelink{include/include}!
      \item
      To get rid of the extra files you can use the
      \verb?--delete? option:
      \begin{cmd}
$ rsync -av --delete /usr/include .
      \end{cmd}
      \begin{response}
sending incremental file list
include/
deleting include/include/xen/privcmd.h
deleting include/include/xen/evtchn.h
....
deleting include/include/FlexLexer.h
deleting include/include/

sent 127401 bytes  received 191 bytes  85061.33 bytes/sec
total size is 41239979  speedup is 323.22
      \end{response}

      \item For another simple exercise,
      remove a subdirectory tree in your backup copy and
      then run \textbf{rsync} again with and without the
      \verb?--dry-run? option:
      \begin{cmd}
$ rm -rf include/xen
$ rsync -av --delete --dry-run /usr/include .
      \end{cmd}
      \begin{response}
sending incremental file list
include/
include/xen/
include/xen/evtchn.h
include/xen/privcmd.h

sent 127412 bytes  received 202 bytes  255228.00 bytes/sec
total size is 41239979  speedup is 323.16 (DRY RUN)
      \end{response}
      \begin{cmd}
$ rsync -av --delete  /usr/include .
      \end{cmd}
      \item  A simple script with a good set of options for using
      \textbf{rsync}:
      \begin{shlst}[script using \textbf{rsync}]
         #!/bin/sh
         set -x

         rsync --progress -avrxH --delete $*
      \end{shlst}
      which will work on a local machine as well as over
      the network.  Note the important \verb?-x? option
      which stops \textbf{rsync} from crossing
      filesystem boundaries.
   \end{enumerate}
   \begin{lfbox}[Extra Credit]
      For more fun, if you have access to more than one computer,
      try doing these steps with source and destination on different
      machines.
   \end{lfbox}
\end{exe}

