📄 0339-0341.html
字号:
<HTML>
<HEAD>
<TITLE>Developer.com - Online Reference Library - 0672311623:SAMS TEACH YOURSELF LINUX IN 24 HOURS:Archiving</TITLE>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>
-->
<!-- ISBN=0672311623 //-->
<!-- TITLE=SAMS TEACH YOURSELF LINUX IN 24 HOURS //-->
<!-- AUTHOR=BILL BALL, STEPHEN SMOOGEN //-->
<!-- PUBLISHER=MACMILLAN //-->
<!-- IMPRINT=SAMS //-->
<!-- PUBLICATION DATE=1998 //-->
<!-- CHAPTER=23 //-->
<!-- PAGES=0339-0346 //-->
<!-- UNASSIGNED1 //-->
<!-- UNASSIGNED2 //-->
<P><CENTER>
<a href="../ch22/0337-0338.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0342-0344.html">Next</A>
</CENTER></P>
<A NAME="PAGENUM-339"><P>Page 339</P></A>
<H3><A NAME="ch23_ 2">
Hour 23
</A></H3>
<H2>
<A NAME="ch23_ 3">
Archiving
</A>
</H2>
<P>This hour continues the discussion of basic system administration skills and shows you
how to back up and restore your system by using several different Linux utilities (included
on your CD-ROM). With a little effort, you'll be able to easily perform these
system administration tasks.
</P>
<H3><A NAME="ch23_ 4">
Considerations Before Performing Backups and Restores
</A></H3>
<P>There are several things you should consider before backing up or restoring your
system. Although one ideal time to back up is after you've installed Linux and made sure all
your devices (such as the sound card, graphics card, or tape drive) are working, there are
other considerations. For example, if the kernel supplied on the CD-ROM works well for
your system, then you can simply rely on the CD for your initial backup in case you have to
do a full restore.
</P>
<P>You should understand the difference between a backup and an archive. Backups
are performed at regular intervals to save important documents, files, or complete
systems.
</P>
<A NAME="PAGENUM-340"><P>Page 340</P></A>
<P>
Archives are made to save important documents, files, or complete systems for long
periods of time. This means that you should first devise a backup strategy and ask yourself
the following questions:
</P>
<UL>
<LI> Do I need to use a formal backup strategy?
<LI> Do I need to back up the entire system each time?
<LI> Do I need to back up selected files or whole directories?
<LI> How often should I do the backup?
<LI> How long do I need to keep my archived copies?
<LI> Do I need reports or statistics on the backups?
<LI> What media (such as floppy or tape) should I use?
<LI> What software format (such as tar or dump) should the backup be in?
<LI> Do I need to use any specialized software tools, such as backup scripts, or can
I perform the backups by hand?
<LI> Should compression, straight copying, or encryption be used?
</UL>
<P>You can answer some of these questions by looking at the way you use your Linux
system. If you're just using Linux for word processing or running spreadsheets, you can
probably get away with only backing up certain files or directories. If you're using Linux to
learn programming, you'll want to keep not only original copies of your programs, but
perhaps different versions. If you have other users on the system, you'll want to not only save
copies of their directories, but the /etc/passwd file, or even the whole system, so that you can
quickly restore the system in the event of a hard drive crash (unlikely) or system operator
error (more likely).
</P>
<P>The size of your system and the capacity of your hard drives or other storage devices
may determine how to approach a backup strategy. If your Linux system is small enough
(around 200MB), you can quickly back up everything to another hard drive or to a tape drive.
You also can use a removable media drive, such as an Iomega Zip drive or Sysquest
EZ-flyer. If you only have to save copies of a small number of small files, you may even be able
to use high-density floppies for storage.
</P>
<P>You'll probably decide on a combination of archiving and regularly scheduled full
or incremental backups. You need to choose the software to use and explore how to
automate as much of the process as possible, perhaps by using
crontab entries (discussed in Hour 24, "Scheduling"). Whatever you do, when you decide on your strategy, stick to it! The
worst time to create and use a backup strategy is after you run into problems or lose files.
</P>
<A NAME="PAGENUM-341"><P>Page 341</P></A>
<H4><A NAME="ch23_ 5">
Backing Up Your System with the tar Command
</A></H4>
<P>Although use of the tar command was discussed in Hour 5, "Manipulation and
Searching Commands," as the system administrator, you'll want to explore some of the more
complex tar command-line options and experiment with creating backups before implementing
your backup strategy.
</P>
<P>The tar command creates a tape archive. You can write the archive to your hard drive,
a tape drive, or nearly any other Linux device. To create a quick backup of your users'
home directories, use tar to create the archive. For example,
</P>
<!-- CODE SNIP //-->
<PRE>
# tar cPfC users.tar / home
</PRE>
<!-- END CODE SNIP //-->
<P>This command line creates the tape archive
users.tar in the current directory. One easy way to regularly back up these directories is to save them on a different file system. If you
have a DOS or Windows partition mounted (see Hour 21, "Handling Files"), automate
the backup process with a crontab entry:
</P>
<!-- CODE SNIP //-->
<PRE>
30 17 * * * root tar cPfC /mnt/dos/windows/desktop/users.tar / home
</PRE>
<!-- END CODE SNIP //-->
<P>This entry, in the /etc/crontab file, backs up your users' directories at 5:30 p.m. each day
and saves the archive in the Windows desktop folder. As you can see, automating the
backup process isn't that hard, and has the benefit of working in the background without
your attention; a process called an unattended backup. If you save your data on a separate
file system, you can easily restore the files later by using the
tar command's x, or extract, option:
</P>
<!-- CODE SNIP //-->
<PRE>
# cd /
# tar xvf /mnt/dos/windows/desktop/users.tar
</PRE>
<!-- END CODE SNIP //-->
<P>These command lines restore your users' directories and files, starting at the
/ or root directory. While backing up files to another file on your hard drive is easy, you also
can use the tar command with tape drives by specifying the tape device on the
tar command line.
</P>
<TABLE BGCOLOR=#FFFF99><TR><TD>JUST A MINUTE</TD></TR><TR><TD>
<BLOCKQUOTE>
Unfortunately, there are no utilities to format tapes under Linux. Although
you must still use a DOS or Windows utility to do this, you won't have to
bother with formatting if you make sure to purchase preformatted tapes.
</BLOCKQUOTE>
</TD></TR></TABLE>
<P>This hour doesn't detail all the ins and outs of installing or using different tape devices,
but it does show you the general approach and some examples you may want to try. To use
a tape drive with the tar command, you must find the tape device under the
/dev directory. There are a number of them, but this section uses the general floppy tape driver,
/dev/ftape, as an example.
</P>
<P><CENTER>
<a href="../ch22/0337-0338.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0342-0344.html">Next</A>
</CENTER></P>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -