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

📄 0342-0344.html

📁 linux-unix130.linux.and.unix.ebooks130 linux and unix ebookslinuxLearning Linux - Collection of 12 E
💻 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="0339-0341.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0345-0346.html">Next</A>

</CENTER></P>



<A NAME="PAGENUM-342"><P>Page 342</P></A>





<P>

Although most tape drives will rewind a freshly inserted tape, you

can use the mt, or magnetic tape command to rewind or re-tension your tape. Insert the tape, then use

the following:</P>





<!-- CODE SNIP //-->

<PRE>

# mt -f /dev/ftape rewind

</PRE>

<!-- END CODE SNIP //-->



<P>After the tape has rewound, erase it with the mt command's erase option:

</P>



<!-- CODE SNIP //-->

<PRE>

# mt -f /dev/ftape erase

</PRE>

<!-- END CODE SNIP //-->



<P>After the tape has been erased, you can write a tar archive to the tape by specifying the

/dev/ftape device:

</P>



<!-- CODE SNIP //-->

<PRE>

# cd /

# tar cf /dev/ftape /home

</PRE>

<!-- END CODE SNIP //-->



<P>This command creates a tape archive of all the files and directories under the

/home directory. To restore your tape archive, you must use the

tar command's extract, or x command-line option:

</P>



<!-- CODE SNIP //-->

<PRE>

# cd /

# tar xf /dev/ftape

</PRE>

<!-- END CODE SNIP //-->



<P>There are many more options with the tar command. You'll want to explore some of

them, such as the d option to test archives, or the z option to compress files (and save tape space). For more information, see the tar manual page and read the ftape-HOWTO under the

/usr/doc directory.

</P>



<H4><A NAME="ch23_ 6">

Using the cpio Command to Backup and Restore

</A></H4>



<P>The cpio, or copy in and out command, may be used in much the same way as the

tar command, but with several differences, especially with archive creation or

extraction command-line options. For example, to create a

cpio archive, you must use the -o, or create, option. The

cpio command also requires a list of filenames, with paths, to build an

archive. To do this, use the find command which handily creates the required names for you.

</P>



<P>For example, if you have a directory called x11 that contains a number of files you'd

like to archive, you can combine the output of the

find command with the cpio command to build the archive.

</P>



<!-- CODE //-->

<PRE>

# find x11 | cpio -ov &gt;x11.cpio

cpio: x11: truncating inode number

x11

x11/xfree86faq.txt

x11/xappsfaq.txt

x11/x11faq.txt

x11/disaster.txt

x11/XHints1.txt

1082 blocks

</PRE>

<!-- END CODE //-->



<A NAME="PAGENUM-343"><P>Page 343</P></A>







<P>This command line shows that the cpio command has been fed the names of the files

inside the x11 directory, creating an archive with the

-o option and showing you the files added with the

-v option. The name of the archive is x11.cpio, and it is created using the

greater than, or &gt;, redirection operator.

</P>



<P>To restore a cpio archive, use the cpio command's extract, or

-i command-line option:

</P>



<!-- CODE SNIP //-->

<PRE>

# cpio -i &lt; x11.cpio

1082 blocks

</PRE>

<!-- END CODE SNIP //-->



<P>This command line shows that to extract a cpio archive you can use the less than, or

&lt;, redirection operator in conjunction with the

-i cpio extract option. The cpio program re-creates the directory and finishes by printing the number of 512-character blocks that

were written to your hard drive.

</P>



<P>You also can use the combination of the find command and

cpio to create archives of any directory, or even different files on your system. To back up all files in your directory

that belong to you, and are less than one day old, (or have been modified in the last day),

you can use the find command's -user and -mtime command-line options:

</P>



<!-- CODE SNIP //-->

<PRE>

# find /home/bball -user bball -mtime -1 -print | cpio -o &gt;today.cpio

</PRE>

<!-- END CODE SNIP //-->



<P>This command line creates a cpio archive, called

today.cpio, which contains all the files you've modified in the last 24 hours. You're only limited by your imagination in how to

devise your backups, and how to back up your system. For more information on the

cpio command, read its manual page. For more information about the

find command, see Hour 5, or read the find manual page.

</P>



<H4><A NAME="ch23_ 7">

Using the taper Script for Tape Drive Backups and Restores

</A></H4>



<P>The taper program, by Yusaf Nagree, is a backup and restore program used to

create compressed or uncompressed archives of selected files or directories. This

program provides a nice interface to creating and maintain tape archives. You also may use

other types of media to do your backups.

</P>



<P>Using the taper command is easy. Specify the type of media to use with the

-T media option. According to the latest documentation, the

taper command supports the following:

</P>



<UL>

<LI>          ftape&#151;The floppy drive tape driver, used for tape drives that attach to the

floppy interface (this driver is included with your Linux system).

<LI>          zftape&#151;A newer floppy drive tape driver that handles additional tape formats.

<LI>          scsi&#151;Driver for tape drives using a SCSI interface.

<LI>          ide&#151;Driver to support IDE tape drives.

<LI>          removeable&#151;Driver to support floppies, or

removable hard drives.

</UL>



<P>If you don't have a tape drive, but would like to try the taper program to test a backup of

</P>

<A NAME="PAGENUM-344"><P>Page 344</P></A>





<P>

a directory or two to floppy diskettes, use the -T command-line option with the

removable option:</P>





<!-- CODE SNIP //-->

<PRE>

# taper -T removable

</PRE>

<!-- END CODE SNIP //-->



<P>This starts the taper program, using the default floppy device,

/dev/fd0. You'll be asked to select the files or directories before you start the backup. The taper program has too

many features to discuss here, but you'll find its documentation under the

/usr/doc directory in the file TAPER.txt.

</P>



<H4><A NAME="ch23_ 8">

Configuring the BRU Backup System for Backups and Restores

</A></H4>



<P>If you purchase Linux from Red Hat Software, a copy of Enhanced Software

Technologies' BRU, or Backup and Restore Utility, is on your CD-ROM (see Figure 23.1). This is

a complete commercial software backup application you can use to back up your system

or files, using nearly any tape drive and even floppies. This section shows you some of

the highlights of this software, which provides data verification, error detection,

data compression, and selective backup and restores. You can use the BRU software from

the command line or while using X11.

</P>



<P>Install the BRU software from your CD-ROM either during the initial install, or later

on, using the control-panel or glint commands (see Hour 22, &quot;Red Hat Tools&quot;). When you

first </P>



<P>Figure 23.1.<BR>

The BRU 2000 backup <br>

and restore utility <br>

features menus and <br>

buttons to manage <br>

Linux system backups.</P>

<P><a href="javascript:displayWindow('images/ch23fg01.jpg', 220, 150)"><img src="images/tn_ch23fg01.jpg"></a><BR>

</P>





<P>

run BRU, you must also tell BRU which device to use to back up your files.

</P>



<P>First, go to the File menu and choose Configure BRU. The BRU Configuration

Utility window appears. Click the Devices button in this window, then click New. A New

Device

</P>

<P><CENTER>

<a href="0339-0341.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0345-0346.html">Next</A>

</CENTER></P>











</td>
</tr>
</table>

<!-- begin footer information -->









</body></html>

⌨️ 快捷键说明

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