forked from pifty/tutes-dump
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
HTML
182 lines
6.4 KiB
HTML
<html><head>
|
|
<title>Backing Up $HOME Using rsync</title>
|
|
|
|
</head><body>
|
|
|
|
<h1>Backing Up $HOME Using rsync</h1>
|
|
<hr />
|
|
|
|
<h2>Content</h2>
|
|
<ul>
|
|
<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>
|
|
<br><UL>
|
|
<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>
|
|
</ul>
|
|
|
|
</ul>
|
|
<br />
|
|
|
|
<h2><a id="why" />Why should I backup?</h2>
|
|
|
|
<P>
|
|
As is <a href="http://sdf.lonestar.org/index.cgi?faq?MISC?01">
|
|
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="http://sdf.lonestar.org/index.cgi?abuse/aup">SDF AUP</a> also clearly
|
|
outlines the fact that taking care of your files is your responsibility.
|
|
</p>
|
|
|
|
<h2><a id="requirements" />Requirements</h2>
|
|
|
|
<p>
|
|
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.
|
|
|
|
</p>
|
|
|
|
<h2><a id="rsync" />Why rsync?</h2>
|
|
|
|
<P>
|
|
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.
|
|
</P>
|
|
|
|
<h2><a id="backup" />Basic rsync backup.</h2>
|
|
|
|
<P>
|
|
Only a portion of rsync's options and capabilities will be discussed
|
|
here. See the rsync man page for further details.
|
|
</p>
|
|
<P>
|
|
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.
|
|
</p>
|
|
|
|
<P>
|
|
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:
|
|
</p>
|
|
<P>
|
|
<code>rsync -avz -e ssh <i>username</i>@sdf.lonestar.org:/path/to/home /local/backup/dir</code>
|
|
</p>
|
|
<P>What does this mean? <br>
|
|
<UL>
|
|
<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>
|
|
|
|
</ul>
|
|
|
|
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.
|
|
</p>
|
|
|
|
<h2><a id="restoring" />Restoring</h2>
|
|
|
|
<P>
|
|
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
|
|
reversed.
|
|
|
|
</p>
|
|
|
|
<h2><a id="caveats" />Caveats and extras</h2>
|
|
|
|
<P>
|
|
<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.
|
|
</p>
|
|
<p>
|
|
For example:
|
|
</p>
|
|
<code>rsync -avz -e ssh username@sdf.lonestar.org:/path/to/home /local/backup/dir</code>
|
|
</p>
|
|
<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.
|
|
</p>
|
|
|
|
<h3><a id="delete">The <code>--delete</code> option</h3>
|
|
|
|
<P>
|
|
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.
|
|
</p>
|
|
|
|
<h3><a id="links">Rsync and symlinks</h3>
|
|
|
|
<P>
|
|
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.
|
|
|
|
</p>
|
|
|
|
<h3><a id="cron">Rsync and Cron</h3>
|
|
|
|
<P>
|
|
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="http://troy.jdmz.net/rsync/index.html">Troy Johnson's</a>
|
|
nice writeup on the subject.
|
|
</P>
|
|
|
|
|
|
|
|
$Id: rsync-backup.html,v 1.3 2007/04/26 18:11:08 avoyager Exp $
|
|
</body>
|
|
</html>
|
|
|
|
|