You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

182 lines
6.4 KiB

<title>Backing Up $HOME Using rsync</title>
<h1>Backing Up $HOME Using rsync</h1>
<hr />
<li><a href="#why">Why should I backup?</a></li>
<li><a href="#requirements">Requirements</a></li>
<li><a href="#rsync">Why rsync?</a></li>
<li><a href="#backup" />Basic rsync backup.</a></li>
<li><a href="#restoring" />Restoring</a></li>
<li><a href="#caveats" />Caveats and extras</a>
<li><a href="#slashes">Trailing directory slashes</a></li>
<li><a href="#delete">The <code>--delete</code> option</a></li>
<li><a href="#links">Rsync and symlinks</a></li>
<li><a href="#cron">Rsync and Cron</a></li></li>
<br />
<h2><a id="why" />Why should I backup?</h2>
As is <a href="">
clearly outlined in the FAQ</a>, SDF backups up system files only. SDF does
NOT maintain backups of userspace. If there is something stored in your
home directory that is important to you then you need to take on the
responsibility of protecting it. Paragraph two of the
<a href="">SDF AUP</a> also clearly
outlines the fact that taking care of your files is your responsibility.
<h2><a id="requirements" />Requirements</h2>
What you will need to perform a mirror of your home directory on SDF to
another location is a computer with ssh and rsync installed and enough space
to store your SDF files. The instructions below are being run on an x86
running Linux, but should be suitable for Mac OS/X and Windows running cygwin.
Please read the ssh and rsync documentation on those platforms for any differences.
<h2><a id="rsync" />Why rsync?</h2>
Rsync will allow you to syncronize your data on SDF to an area on another
computer. Using rsync will enable you to copy only new files or files that
have changed. This saves bandwidth for both parties and greatly speeds up
the operation.
Rsync is in current development, open source, and very flexible. It is
possible to create a variety of different backups using rsync.
<h2><a id="backup" />Basic rsync backup.</h2>
Only a portion of rsync's options and capabilities will be discussed
here. See the rsync man page for further details.
You may want to add the switch "-n" to your rsync commands while setting
things up and testing. This option causes rsync to do a "dry run",
executing the command and producing output without actually
manipulating files.
You will be using rsync on a machine to CONNECT TO SDF. What follows is NOT designed
to be run from SDF. On the machine
you wish to backup your SDF home directory to, issue the following:
<code>rsync -avz -e ssh <i>username</i> /local/backup/dir</code>
<P>What does this mean? <br>
<LI><code>-a</code> : archive mode. This preserves
timestamps, owner and group information, mirrors recursivly, and copies
symlinks as links. If you'd like to copy the link's referent, you will
need to add the "-L" switch.</LI>
<LI><code>-v</code> : verbose mode. The names of files being copied will
be sent to SDTOUT along with other information.</LI>
<LI><code>-z</code> : compress data being transmited.</LI>
<LI><code>-e</code> : specify the shell to be used. This is being used
here to rsync over a secure shell connection.</li>
<li><i>username</i> : your SDF username.</li>
<li><code>/path/to/home</code> <a href="#caveat01">[1]</a> : The path to
the directory you wish to backup.</li>
<li><code>/local/backup/dir</code> : Where you would like the files to be
stored locally.</li>
You will be prompted for your SDF password. Upon completion, rsync will
report a few statistics to you such as the amount of data transfered and
your average throughput. When you run this command subsiquently rsync
will only backup new and changed files.
<h2><a id="restoring" />Restoring</h2>
Restoring a single file is as easy as using <code>sftp</code> or
<code>scp</code> to transfer the file from your backup directory back
to SDF. To restore your entire directory, simply issue the rsync command
you used for backing up your SDF data with the source and destination
<h2><a id="caveats" />Caveats and extras</h2>
<h3><a id="slashes">Trailing directory slashes</h3>
Most often, the trailing slash when specifying a directory is optional.
To rsync, however, the trailing slash has meaning when specifying the
source directory. Omitting the trailing slash cause the entire directory
structure of the source files to be recreated on the destination machine.
Specifying the trailing slash, however, causes the directory structure
only to be recreated from the given directory.
For example:
<code>rsync -avz -e ssh /local/backup/dir</code>
<P>The above would produce <code>/local/backup/dir/path/to/home</code> on
the destination machine. Adding the trailing slash on the source
directory would simply dump the contents of of the directory into the
destination dir.
<h3><a id="delete">The <code>--delete</code> option</h3>
Rsync's default behavior is to copy and update files on the source to
the destination. If a file is removed from the source directory it is
retained at the destination. Adding the <code>--delete</code> option
causes files removed from the source directory to also be removed
from the destination.
<h3><a id="links">Rsync and symlinks</h3>
As stated above, the default behavior for copying links with rsync's
"-a" option is to copy simlinks as links. On sdf $HOME/html and
$HOME/gopher are links and will not be backed up unless you
either specify the full path to those directories as separate
backups or you add the "-L" option after the "-a" option to
your rsync backup.
<h3><a id="cron">Rsync and Cron</h3>
Backups work best if they are done regularly. A nice way to make sure
you don't forget to make regular backups is to have your computer
remember for you by placing your rsync command in a cron job. Due to
a password being involved, this is not a completly straightforward task
and some caution is required. For a very good first read on this subject,
please read <a href="">Troy Johnson's</a>
nice writeup on the subject.
$Id: rsync-backup.html,v 1.3 2007/04/26 18:11:08 avoyager Exp $