\begin{exe} {Using tar for Backup}

   \begin{enumerate}
      \item
      Create a directory called \verb?backup? and in it
      place a compressed \textbf{tar} archive of all the
      files under \filelink{/usr/include}, with the highest
      level directory being \verb?include?.  You can use
      any compression method (\textbf{gzip}, \textbf{bzip2}
      or \textbf{xzip}).
      \item
      List the files in the archive.
      \item
      Create a directory called \verb?restore? and
      unpack and decompress the archive.
      \item
      Compare the
      contents with the original directory the archive
      was made from.
   \end{enumerate}

   \begin{sol}

      \begin{enumerate}
         \item
         \begin{cmd}
$ mkdir /tmp/backup
$ cd /usr ; tar zcvf /tmp/backup/include.tar.gz include
$ cd /usr ; tar jcvf /tmp/backup/include.tar.bz2 include
$ cd /usr ; tar Jcvf /tmp/backup/include.tar.xz include
         \end{cmd}
         or
         \begin{cmd}
$ tar -C /usr -zcf include.tar.gz include
$ tar -C /usr -jcf include.tar.bz2 include
$ tar -C /usr -Jcf include.tar.xz include
         \end{cmd}
         Notice the efficacy of the compression between the three
         methods:
         \begin{cmd}
$ du -sh /usr/include
         \end{cmd}
         \begin{response}
55M	/usr/include
         \end{response}
         \item
         \begin{cmd}
$ ls -lh include.tar.*
         \end{cmd}
         \begin{response}
c8:/tmp/backup>ls -lh
total 17M
-rw-rw-r-- 1 coop coop 5.3M Jul 18 08:17 include.tar.bz2
-rw-rw-r-- 1 coop coop 6.7M Jul 18 08:16 include.tar.gz
-rw-rw-r-- 1 coop coop 4.5M Jul 18 08:18 include.tar.xz
         \end{response}
         \item
         \begin{cmd}
$ tar tvf include.tar.xz
         \end{cmd}
         \begin{response}
qdrwxr-xr-x root/root         0 2014-10-29 07:04 include/
-rw-r--r-- root/root     42780 2014-08-26 12:24 include/unistd.h
-rw-r--r-- root/root       957 2014-08-26 12:24 include/re_comp.h
-rw-r--r-- root/root     22096 2014-08-26 12:24 include/regex.h
-rw-r--r-- root/root      7154 2014-08-26 12:25 include/link.h
.....
         \end{response}
         Note it is not necessary to give the \verb?j?,
         \verb?J?, or \verb?z?  option when decompressing;
         \textbf{tar} is smart enough to figure out what is
         needed.
         \item
         \begin{cmd}
$ cd .. ; mkdir restore ; cd restore
$ tar xvf ../backup/include.tar.bz2
         \end{cmd}
         \begin{response}
include/
include/unistd.h
include/re_comp.h
include/regex.h
include/link
.....
$ diff -qr include /usr/include
         \end{response}
      \end{enumerate}
   \end{sol}
\end{exe}

