—delete—Deletes extraneous  files   from    destination directories.
—delete-excluded—Also   deletes excluded    files   from    destination
directories.
—exclude-from=/home/matt-exclude.txt—Prevents   backing
up  files   or  directories listed  in  this    file.   (It is  a   simple  list    with    each
excluded    directory   on  its own line.)
—backup—Creates backups of  files   before  deleting    them    from    a
currently   existing    backup.
—backup-dir=‘date   +%Y-%m-%d’—Creates  a   backup  directory
for the previously  mentioned   files   that    looks   like    this:   2013-07-08. Why
this    format  for the date?   Because it  is  standard,   as  outlined    in  ISO 8601
(see    http://www.iso.org/iso/home/standards/iso8601.htm). It  is  clear,
works   with    scripts,    and sorts   beautifully,    making  your    files   easy    to  find.
-av—Tells   rsync   to  use archive mode    and verbose mode./—Denotes   the directory   to  backup. In  this    case,   it  is  the root    directory   of
the source, so  everything  in  the file    system  is  being   backed  up. You
could   put /home   here    to  backup  all user    directories or  make    a   nice    list
of  directories to  exclude in  the file    system.
/media/externaldrive/backup/seymour—Sets    the destination
for the backup  as  the /backup/seymour directory   on  an  external
hard    drive   mounted at  /mount /externaldrive.To  restore from    this    backup  to  the same    original    location,   you reverse some    of
the details and may omit    others. Something   like    this    works   nicely:
Click   here    to  view    code    image
matthew@seymour:~$  rsync   --force --ignore-errors --delete    --delete-
excluded
/media/externaldrive/backup/seymour /
This    becomes even    more    useful  when    you think   of  ways    to  script  its use.    You
could   create  an  entry   in  crontab,    as  described   in  Chapter 14, “Automating
Tasks   and Shell   Scripting.” Even    better, you could   set two computers   to  allow
for remote  SSH connections using   private keys    created with    ssh-keygen,
as  described   in  Chapter 19, “Remote Access  with    SSH,    Telnet, and VNC,”   so
that    one could   backup  the files   from    one computer    to  the other   computer
without requiring   manual  login.  Then    you could   place   that    in  an  automated
script.