⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 backup-basics.html

📁 FreeBSD操作系统的详细使用手册
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta name="generator" content="HTML Tidy, see www.w3.org" /><title>Backup Basics</title><meta name="GENERATOR" content="Modular DocBook HTML Stylesheet Version 1.7" /><link rel="HOME" title="FreeBSD Handbook" href="index.html" /><link rel="UP" title="Storage" href="disks.html" /><link rel="PREVIOUS" title="Backups to Floppies" href="backups-floppybackups.html" /><link rel="NEXT" title="Network, Memory, and File-Backed File Systems"href="disks-virtual.html" /><link rel="STYLESHEET" type="text/css" href="docbook.css" /></head><body class="SECT1" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#840084"alink="#0000FF"><div class="NAVHEADER"><table summary="Header navigation table" width="100%" border="0" cellpadding="0"cellspacing="0"><tr><th colspan="3" align="center">FreeBSD Handbook</th></tr><tr><td width="10%" align="left" valign="bottom"><a href="backups-floppybackups.html"accesskey="P">Prev</a></td><td width="80%" align="center" valign="bottom">Chapter 16 Storage</td><td width="10%" align="right" valign="bottom"><a href="disks-virtual.html"accesskey="N">Next</a></td></tr></table><hr align="LEFT" width="100%" /></div><div class="SECT1"><h1 class="SECT1"><a id="BACKUP-BASICS" name="BACKUP-BASICS">16.11 Backup Basics</a></h1><p>The three major backup programs are <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=dump&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">dump</span>(8)</span></a>, <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=tar&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">tar</span>(1)</span></a>, and <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=cpio&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">cpio</span>(1)</span></a>.</p><div class="SECT2"><h2 class="SECT2"><a id="AEN24803" name="AEN24803">16.11.1 Dump and Restore</a></h2><p>The traditional <span class="TRADEMARK">UNIX</span>&reg; backup programs are <ttclass="COMMAND">dump</tt> and <tt class="COMMAND">restore</tt>. They operate on the driveas a collection of disk blocks, below the abstractions of files, links and directoriesthat are created by the file systems. <tt class="COMMAND">dump</tt> backs up an entirefile system on a device. It is unable to backup only part of a file system or a directorytree that spans more than one file system. <tt class="COMMAND">dump</tt> does not writefiles and directories to tape, but rather writes the raw data blocks that comprise filesand directories.</p><div class="NOTE"><blockquote class="NOTE"><p><b>Note:</b> If you use <tt class="COMMAND">dump</tt> on your root directory, youwould not back up <tt class="FILENAME">/home</tt>, <tt class="FILENAME">/usr</tt> or manyother directories since these are typically mount points for other file systems orsymbolic links into those file systems.</p></blockquote></div><p><tt class="COMMAND">dump</tt> has quirks that remain from its early days in Version 6of AT&amp;T UNIX (circa 1975). The default parameters are suitable for 9-track tapes(6250 bpi), not the high-density media available today (up to 62,182 ftpi). Thesedefaults must be overridden on the command line to utilize the capacity of current tapedrives.</p><p>It is also possible to backup data across the network to a tape drive attached toanother computer with <tt class="COMMAND">rdump</tt> and <ttclass="COMMAND">rrestore</tt>. Both programs rely upon <tt class="COMMAND">rcmd</tt> and<tt class="COMMAND">ruserok</tt> to access the remote tape drive. Therefore, the userperforming the backup must be listed in the <tt class="FILENAME">.rhosts</tt> file on theremote computer. The arguments to <tt class="COMMAND">rdump</tt> and <ttclass="COMMAND">rrestore</tt> must be suitable to use on the remote computer. When <ttclass="COMMAND">rdump</tt>ing from a FreeBSD computer to an Exabyte tape drive connectedto a Sun called <tt class="HOSTID">komodo</tt>, use:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbdclass="USERINPUT">/sbin/rdump 0dsbfu 54000 13000 126 komodo:/dev/nsa8 /dev/da0a 2&#62;&amp;1</kbd></pre><p>Beware: there are security implications to allowing <tt class="FILENAME">.rhosts</tt>authentication. Evaluate your situation carefully.</p><p>It is also possible to use <tt class="COMMAND">dump</tt> and <ttclass="COMMAND">restore</tt> in a more secure fashion over <ttclass="COMMAND">ssh</tt>.</p><div class="EXAMPLE"><a id="AEN24849" name="AEN24849"></a><p><b>Example 16-1. Using <tt class="COMMAND">dump</tt> over ssh</b></p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbdclass="USERINPUT">/sbin/dump -0uan -f - /usr | gzip -2 | ssh -c blowfish \          targetuser@targetmachine.example.com dd of=/mybigfiles/dump-usr-l0.gz</kbd></pre></div><p>Or using <tt class="COMMAND">dump</tt>'s built-in method, setting the environmentvariable <tt class="ENVAR">RSH</tt>:</p><div class="EXAMPLE"><a id="AEN24859" name="AEN24859"></a><p><b>Example 16-2. Using <tt class="COMMAND">dump</tt> over ssh with <ttclass="ENVAR">RSH</tt> set</b></p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbdclass="USERINPUT">RSH=/usr/bin/ssh /sbin/dump -0uan -f targetuser@targetmachine.example.com:/dev/sa0</kbd></pre></div></div><div class="SECT2"><h2 class="SECT2"><a id="AEN24867" name="AEN24867">16.11.2 <ttclass="COMMAND">tar</tt></a></h2><p><a href="http://www.FreeBSD.org/cgi/man.cgi?query=tar&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">tar</span>(1)</span></a> also dates backto Version 6 of AT&amp;T UNIX (circa 1975). <tt class="COMMAND">tar</tt> operates incooperation with the file system; <tt class="COMMAND">tar</tt> writes files anddirectories to tape. <tt class="COMMAND">tar</tt> does not support the full range ofoptions that are available from <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=cpio&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">cpio</span>(1)</span></a>, but <ttclass="COMMAND">tar</tt> does not require the unusual command pipeline that <ttclass="COMMAND">cpio</tt> uses.</p><p>Most versions of <tt class="COMMAND">tar</tt> do not support backups across thenetwork. The GNU version of <tt class="COMMAND">tar</tt>, which FreeBSD utilizes,supports remote devices using the same syntax as <tt class="COMMAND">rdump</tt>. To <ttclass="COMMAND">tar</tt> to an Exabyte tape drive connected to a Sun called <ttclass="HOSTID">komodo</tt>, use:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbdclass="USERINPUT">/usr/bin/tar cf komodo:/dev/nsa8 . 2&#62;&amp;1</kbd></pre><p>For versions without remote device support, you can use a pipeline and <ttclass="COMMAND">rsh</tt> to send the data to a remote tape drive.</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">tar cf - . | rsh <varclass="REPLACEABLE">hostname</var> dd of=<varclass="REPLACEABLE">tape-device</var> obs=20b</kbd></pre><p>If you are worried about the security of backing up over a network you should use the<tt class="COMMAND">ssh</tt> command instead of <tt class="COMMAND">rsh</tt>.</p></div><div class="SECT2"><h2 class="SECT2"><a id="AEN24908" name="AEN24908">16.11.3 <ttclass="COMMAND">cpio</tt></a></h2><p><a href="http://www.FreeBSD.org/cgi/man.cgi?query=cpio&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">cpio</span>(1)</span></a> is theoriginal <span class="TRADEMARK">UNIX</span> file interchange tape program for magneticmedia. <tt class="COMMAND">cpio</tt> has options (among many others) to performbyte-swapping, write a number of different archive formats, and pipe the data to otherprograms. This last feature makes <tt class="COMMAND">cpio</tt> an excellent choice forinstallation media. <tt class="COMMAND">cpio</tt> does not know how to walk the directorytree and a list of files must be provided through <tt class="FILENAME">stdin</tt>.</p><p><tt class="COMMAND">cpio</tt> does not support backups across the network. You can usea pipeline and <tt class="COMMAND">rsh</tt> to send the data to a remote tape drive.</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">for f in <varclass="REPLACEABLE">directory_list; do</var></kbd><kbd class="USERINPUT">find $f &#62;&#62; backup.list</kbd><kbd class="USERINPUT">done</kbd><samp class="PROMPT">#</samp> <kbdclass="USERINPUT">cpio -v -o --format=newc &#60; backup.list | ssh <varclass="REPLACEABLE">user</var>@<var class="REPLACEABLE">host</var> "cat &#62; <varclass="REPLACEABLE">backup_device</var>"</kbd></pre><p>Where <var class="REPLACEABLE">directory_list</var> is the list of directories youwant to back up, <var class="REPLACEABLE">user</var>@<var class="REPLACEABLE">host</var>is the user/hostname combination that will be performing the backups, and <varclass="REPLACEABLE">backup_device</var> is where the backups should be written to (e.g.,<tt class="FILENAME">/dev/nsa0</tt>).</p></div><div class="SECT2"><h2 class="SECT2"><a id="AEN24947" name="AEN24947">16.11.4 <ttclass="COMMAND">pax</tt></a></h2><p><a href="http://www.FreeBSD.org/cgi/man.cgi?query=pax&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">pax</span>(1)</span></a> is IEEE/<spanclass="TRADEMARK">POSIX</span>&reg;'s answer to <tt class="COMMAND">tar</tt> and <ttclass="COMMAND">cpio</tt>. Over the years the various versions of <ttclass="COMMAND">tar</tt> and <tt class="COMMAND">cpio</tt> have gotten slightlyincompatible. So rather than fight it out to fully standardize them, <spanclass="TRADEMARK">POSIX</span> created a new archive utility. <ttclass="COMMAND">pax</tt> attempts to read and write many of the various <ttclass="COMMAND">cpio</tt> and <tt class="COMMAND">tar</tt> formats, plus new formats ofits own. Its command set more resembles <tt class="COMMAND">cpio</tt> than <ttclass="COMMAND">tar</tt>.</p></div><div class="SECT2"><h2 class="SECT2"><a id="BACKUPS-PROGRAMS-AMANDA" name="BACKUPS-PROGRAMS-AMANDA">16.11.5<b class="APPLICATION">Amanda</b></a></h2><p><b class="APPLICATION">Amanda</b> (Advanced Maryland Network Disk Archiver) is aclient/server backup system, rather than a single program. An <bclass="APPLICATION">Amanda</b> server will backup to a single tape drive any number ofcomputers that have <b class="APPLICATION">Amanda</b> clients and a network connection tothe <b class="APPLICATION">Amanda</b> server. A common problem at sites with a number oflarge disks is that the length of time required to backup to data directly to tapeexceeds the amount of time available for the task. <b class="APPLICATION">Amanda</b>solves this problem. <b class="APPLICATION">Amanda</b> can use a ``holding disk'' tobackup several file systems at the same time. <b class="APPLICATION">Amanda</b> creates``archive sets'': a group of tapes used over a period of time to create full backups ofall the file systems listed in <b class="APPLICATION">Amanda</b>'s configuration file.The ``archive set'' also contains nightly incremental (or differential) backups of allthe file systems. Restoring a damaged file system requires the most recent full backupand the incremental backups.</p><p>The configuration file provides fine control of backups and the network traffic that<b class="APPLICATION">Amanda</b> generates. <b class="APPLICATION">Amanda</b> will useany of the above backup programs to write the data to tape. <bclass="APPLICATION">Amanda</b> is available as either a port or a package, it is notinstalled by default.</p></div><div class="SECT2"><h2 class="SECT2"><a id="AEN25002" name="AEN25002">16.11.6 Do Nothing</a></h2><p>``Do nothing'' is not a computer program, but it is the most widely used backupstrategy. There are no initial costs. There is no backup schedule to follow. Just say no.If something happens to your data, grin and bear it!</p><p>If your time and your data is worth little to nothing, then ``Do nothing'' is the mostsuitable backup program for your computer. But beware, <spanclass="TRADEMARK">UNIX</span> is a useful tool, you may find that within six months youhave a collection of files that are valuable to you.</p><p>``Do nothing'' is the correct backup method for <tt class="FILENAME">/usr/obj</tt> andother directory trees that can be exactly recreated by your computer. An example is thefiles that comprise the HTML or <span class="TRADEMARK">PostScript</span>&reg; version ofthis Handbook. These document formats have been created from SGML input files. Creatingbackups of the HTML or <span class="TRADEMARK">PostScript</span> files is not necessary.The SGML files are backed up regularly.</p></div><div class="SECT2"><h2 class="SECT2"><a id="AEN25014" name="AEN25014">16.11.7 Which Backup Program IsBest?</a></h2><p><a href="http://www.FreeBSD.org/cgi/man.cgi?query=dump&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">dump</span>(8)</span></a> <spanclass="emphasis"><i class="EMPHASIS">Period.</i></span> Elizabeth D. Zwicky torturetested all the backup programs discussed here. The clear choice for preserving all yourdata and all the peculiarities of <span class="TRADEMARK">UNIX</span> file systems is <ttclass="COMMAND">dump</tt>. Elizabeth created file systems containing a large variety ofunusual conditions (and some not so unusual ones) and tested each program by doing abackup and restore of those file systems. The peculiarities included: files with holes,files with holes and a block of nulls, files with funny characters in their names,unreadable and unwritable files, devices, files that change size during the backup, filesthat are created/deleted during the backup and more. She presented the results at LISA Vin Oct. 1991. See <a href="http://berdmann.dyndns.org/zwicky/testdump.doc.html"target="_top">torture-testing Backup and Archive Programs</a>.</p></div><div class="SECT2"><h2 class="SECT2"><a id="AEN25026" name="AEN25026">16.11.8 Emergency RestoreProcedure</a></h2>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -