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

📄 ch20_01.htm

📁 the unix power tools
💻 HTM
字号:
<HTML><!--Distributed by F --><HEAD><TITLE>[Chapter 20] Backing Up Files</TITLE><METANAME="DC.title"CONTENT="UNIX Power Tools"><METANAME="DC.creator"CONTENT="Jerry Peek, Tim O'Reilly &amp; Mike Loukides"><METANAME="DC.publisher"CONTENT="O'Reilly &amp; Associates, Inc."><METANAME="DC.date"CONTENT="1998-10-23T15:44:47Z"><METANAME="DC.type"CONTENT="Text.Monograph"><METANAME="DC.format"CONTENT="text/html"SCHEME="MIME"><METANAME="DC.source"CONTENT="1-56592-260-3"SCHEME="ISBN"><METANAME="DC.language"CONTENT="en-US"><METANAME="generator"CONTENT="Jade 1.1/O'Reilly DocBook 3.0 to HTML 4.0"><LINKREV="made"HREF="mailto:online-books@oreilly.com"TITLE="Online Books Comments"><LINKREL="up"HREF="part03.htm"TITLE="III. Working with the Filesystem "><LINKREL="prev"HREF="ch19_09.htm"TITLE="19.9 A System V Tape Archiver: cpio "><LINKREL="next"HREF="ch20_02.htm"TITLE="20.2 Make Your Own Backups "></HEAD><BODYBGCOLOR="#FFFFFF"TEXT="#000000"><DIVCLASS="htmlnav"><H1><IMGSRC="gifs/smbanner.gif"ALT="UNIX Power Tools"USEMAP="#srchmap"BORDER="0"></H1><MAPNAME="srchmap"><AREASHAPE="RECT"COORDS="0,0,466,58"HREF="index.htm"ALT="UNIX Power Tools"><AREASHAPE="RECT"COORDS="467,0,514,18"HREF="jobjects/fsearch.htm"ALT="Search this book"></MAP><TABLEWIDTH="515"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch19_09.htm"TITLE="19.9 A System V Tape Archiver: cpio "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 19.9 A System V Tape Archiver: cpio "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><B><FONTFACE="ARIEL,HELVETICA,HELV,SANSERIF"SIZE="-1">Chapter 20</FONT></B></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch20_02.htm"TITLE="20.2 Make Your Own Backups "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 20.2 Make Your Own Backups "BORDER="0"></A></TD></TR></TABLE>&nbsp;<HRALIGN="LEFT"WIDTH="515"TITLE="footer"></DIV><DIVCLASS="CHAPTER"><H1CLASS="chapter"><ACLASS="title"NAME="UPT-CHP-20">20. Backing Up Files</A></H1><DIVCLASS="htmltoc"><P><B>Contents:</B><BR><ACLASS="sect1"HREF="#UPT-ART-8024"TITLE="20.1 tar in a Nutshell ">tar in a Nutshell </A><BR><ACLASS="sect1"HREF="ch20_02.htm"TITLE="20.2 Make Your Own Backups ">Make Your Own Backups </A><BR><ACLASS="sect1"HREF="ch20_03.htm"TITLE="20.3 How to Make Backups with a Local Tape Drive ">How to Make Backups with a Local Tape Drive </A><BR><ACLASS="sect1"HREF="ch20_04.htm"TITLE="20.4 Restoring Files from Tape with tar ">Restoring Files from Tape with tar </A><BR><ACLASS="sect1"HREF="ch20_05.htm"TITLE="20.5 Using tar to a Remote Tape Drive ">Using tar to a Remote Tape Drive </A><BR><ACLASS="sect1"HREF="ch20_06.htm"TITLE="20.6 Writing a Tape Drive on a Remote Machine ">Writing a Tape Drive on a Remote Machine </A><BR><ACLASS="sect1"HREF="ch20_07.htm"TITLE="20.7 Creating a Timestamp File for Selective Backups ">Creating a Timestamp File for Selective Backups </A><BR><ACLASS="sect1"HREF="ch20_08.htm"TITLE="20.8 Telling tar Which Files to Exclude or Include ">Telling tar Which Files to Exclude or Include </A><BR><ACLASS="sect1"HREF="ch20_09.htm"TITLE="20.9 When a Program Doesn't Understand Wildcards ">When a Program Doesn't Understand Wildcards </A><BR><ACLASS="sect1"HREF="ch20_10.htm"TITLE="20.10 Avoid Absolute Paths with tar ">Avoid Absolute Paths with tar </A><BR><ACLASS="sect1"HREF="ch20_11.htm"TITLE="20.11 Getting tar's Arguments in the Right Order ">Getting tar's Arguments in the Right Order </A><BR><ACLASS="sect1"HREF="ch20_12.htm"TITLE="20.12 Protecting Files with SCCS or RCS ">Protecting Files with SCCS or RCS </A><BR><ACLASS="sect1"HREF="ch20_13.htm"TITLE="20.13 SCCS Basics ">SCCS Basics </A><BR><ACLASS="sect1"HREF="ch20_14.htm"TITLE="20.14 RCS Basics ">RCS Basics </A><BR><ACLASS="sect1"HREF="ch20_15.htm"TITLE="20.15 List RCS Revision Numbers with rcsrevs ">List RCS Revision Numbers with rcsrevs </A></P><P></P></DIV><DIVCLASS="sect1"><H2CLASS="sect1"><ACLASS="title"NAME="UPT-ART-8024">20.1 tar in a Nutshell </A></H2><PCLASS="para"><ACLASS="indexterm"NAME="UPT-ART-8024-IX-FILES-BACKING-UP"></A><ACLASS="indexterm"NAME="UPT-ART-8024-IX-BACKUPS"></A><ACLASS="indexterm"NAME="AUTOID-21701"></A><ACLASS="indexterm"NAME="AUTOID-21703"></A>When many UNIX users think of file archives, on tape or in an archivefile, they think of the <EMCLASS="emphasis">tar</EM> utility.There are other ways to make archives and handle tapes&nbsp;- including<SPANCLASS="link"><EMCLASS="emphasis">cpio</EM> (<ACLASS="linkend"HREF="ch19_09.htm"TITLE="A System V Tape Archiver: cpio ">19.9</A>)</SPAN>,<SPANCLASS="link"><EMCLASS="emphasis">shar</EM> (<ACLASS="linkend"HREF="ch19_02.htm"TITLE="Introduction to Shell Archives ">19.2</A>)</SPAN>,and<SPANCLASS="link"><EMCLASS="emphasis">dd</EM> (<ACLASS="linkend"HREF="ch20_06.htm"TITLE="Writing a Tape Drive on a Remote Machine ">20.6</A>)</SPAN>.This article summarizes articles about <EMCLASS="emphasis">tar</EM>-in this chapter and others.</P><ULCLASS="itemizedlist"><LICLASS="listitem"><PCLASS="para">Although <EMCLASS="emphasis">tar</EM> is a <EMCLASS="emphasis">t</EM>ape <EMCLASS="emphasis">ar</EM>chiver,one of its common uses is<SPANCLASS="link">making an archive file on disk (<ACLASS="linkend"HREF="ch19_05.htm"TITLE="Using tar to Create and Unpack Archives ">19.5</A>)</SPAN>.Because <EMCLASS="emphasis">tar</EM> &quot;pads&quot; its archives with<SPANCLASS="link">NUL characters (<ACLASS="linkend"HREF="ch51_03.htm"TITLE="ASCII Characters: Listing and Getting Values ">51.3</A>)</SPAN>,on-disk <EMCLASS="emphasis">tar</EM> archive files can be much bigger than the size of theindividual files put together.The file can be compressed&nbsp;- so you may need to<SPANCLASS="link">uncompress an archive (<ACLASS="linkend"HREF="ch19_07.htm"TITLE="Extracting Files from a Compressed Archive ">19.7</A>)</SPAN>.The<SPANCLASS="link">GNU <EMCLASS="emphasis">tar</EM> (<ACLASS="linkend"HREF="ch19_06.htm"TITLE="GNU tar Sampler ">19.6</A>)</SPAN>can compress files while storing them.If you make on-disk archives,be careful with <EMCLASS="emphasis">tar</EM>'s <EMCLASS="emphasis">v</EM> (verbose) flag or you could endup with a corrupted archive that holds<SPANCLASS="link">more than your files (<ACLASS="linkend"HREF="ch19_08.htm"TITLE="Problems with Verbose tar ">19.8</A>)</SPAN>.</P><PCLASS="para">With compression, a <EMCLASS="emphasis">tar</EM> archive<SPANCLASS="link">can take less disk space (<ACLASS="linkend"HREF="ch24_08.htm"TITLE="Save Space: tar and compress a Directory Tree ">24.8</A>)</SPAN>than compressing individual small files.</P><PCLASS="para">Because <EMCLASS="emphasis">tar</EM> keeps most of a file's<SPANCLASS="link">inode (<ACLASS="linkend"HREF="ch01_22.htm"TITLE="How UNIX Keeps Track of Files: Inodes ">1.22</A>)</SPAN>information, it can make a<SPANCLASS="link">more complete copy (<ACLASS="linkend"HREF="ch18_16.htm"TITLE="Copying Directory Trees with (tar | tar) ">18.16</A>)</SPAN>of a file or directory tree than utilities like <EMCLASS="emphasis">cp</EM>.</P></LI><LICLASS="listitem"><PCLASS="para">Yes, we do have articles about archives on tape.Bruce Barnett's article<ACLASS="xref"HREF="ch20_02.htm"TITLE="Make Your Own Backups ">20.2</A>has enough information to make your own archive... although you mightneed the details from article<ACLASS="xref"HREF="ch20_03.htm"TITLE="How to Make Backups with a Local Tape Drive ">20.3</A>,too.After you've made an archive, you'll probably want to restoreit&nbsp;- at least as a test to be sure your archive is okay.Article<ACLASS="xref"HREF="ch20_04.htm"TITLE="Restoring Files from Tape with tar ">20.4</A>explains how.</P><PCLASS="para">If there isn't a tape drive on your computer, read article<ACLASS="xref"HREF="ch20_05.htm"TITLE="Using tar to a Remote Tape Drive ">20.5</A>about using a drive on another computer.If that isn't enough information, read the gory details from another of ourlong-time UNIX and tape experts, Chris Torek, in article<ACLASS="xref"HREF="ch20_06.htm"TITLE="Writing a Tape Drive on a Remote Machine ">20.6</A>.</P></LI></UL><PCLASS="para"></P><ULCLASS="itemizedlist"><LICLASS="listitem"><PCLASS="para"><EMCLASS="emphasis">tar</EM> copies<ACLASS="indexterm"NAME="AUTOID-21750"></A><ACLASS="indexterm"NAME="AUTOID-21753"></A>a directory tree, recursively, from top to bottom.What if you don't want to archive everything?You can back up just some files by<SPANCLASS="link">combining <EMCLASS="emphasis">ls -lt</EM> and <EMCLASS="emphasis">find</EM> (<ACLASS="linkend"HREF="ch20_07.htm"TITLE="Creating a Timestamp File for Selective Backups ">20.7</A>)</SPAN>.Some versions of <EMCLASS="emphasis">tar</EM> have options for<SPANCLASS="link">including or excluding certain files and directories (<ACLASS="linkend"HREF="ch20_08.htm"TITLE="Telling tar Which Files to Exclude or Include ">20.8</A>, <ACLASS="linkend"HREF="ch19_06.htm"TITLE="GNU tar Sampler ">19.6</A>)</SPAN>.</P></LI></UL><DIVCLASS="sect1info"><PCLASS="SECT1INFO">- <SPANCLASS="authorinitials">JP</SPAN></P></DIV></DIV></DIV><DIVCLASS="htmlnav"><P></P><HRALIGN="LEFT"WIDTH="515"TITLE="footer"><TABLEWIDTH="515"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch19_09.htm"TITLE="19.9 A System V Tape Archiver: cpio "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 19.9 A System V Tape Archiver: cpio "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><ACLASS="book"HREF="index.htm"TITLE="UNIX Power Tools"><IMGSRC="gifs/txthome.gif"SRC="gifs/txthome.gif"ALT="UNIX Power Tools"BORDER="0"></A></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch20_02.htm"TITLE="20.2 Make Your Own Backups "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 20.2 Make Your Own Backups "BORDER="0"></A></TD></TR><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172">19.9 A System V Tape Archiver: cpio </TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><ACLASS="index"HREF="index/idx_0.htm"TITLE="Book Index"><IMGSRC="gifs/index.gif"SRC="gifs/index.gif"ALT="Book Index"BORDER="0"></A></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172">20.2 Make Your Own Backups </TD></TR></TABLE><HRALIGN="LEFT"WIDTH="515"TITLE="footer"><IMGSRC="gifs/smnavbar.gif"SRC="gifs/smnavbar.gif"USEMAP="#map"BORDER="0"ALT="The UNIX CD Bookshelf Navigation"><MAPNAME="map"><AREASHAPE="RECT"COORDS="0,0,73,21"HREF="../index.htm"ALT="The UNIX CD Bookshelf"><AREASHAPE="RECT"COORDS="74,0,163,21"HREF="index.htm"ALT="UNIX Power Tools"><AREASHAPE="RECT"COORDS="164,0,257,21"HREF="../unixnut/index.htm"ALT="UNIX in a Nutshell"><AREASHAPE="RECT"COORDS="258,0,321,21"HREF="../vi/index.htm"ALT="Learning the vi Editor"><AREASHAPE="RECT"COORDS="322,0,378,21"HREF="../sedawk/index.htm"ALT="sed &amp; awk"><AREASHAPE="RECT"COORDS="379,0,438,21"HREF="../ksh/index.htm"ALT="Learning the Korn Shell"><AREASHAPE="RECT"COORDS="439,0,514,21"HREF="../lrnunix/index.htm"ALT="Learning the UNIX Operating System"></MAP></DIV></BODY></HTML>

⌨️ 快捷键说明

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