<chapter id="bkupsavefiles-17924"><title>Copying UFS Files and File Systems
(Tasks)</title><highlights><para>This chapter describes how to copy UFS files and file systems to disk,
tape, and diskettes by using various backup commands.</para><para>This is a list of the step-by-step instructions in this chapter.</para><itemizedlist><listitem><para><olink targetptr="bkupsavefiles-60904" remap="internal">How to Copy a Disk
(dd)</olink></para>
</listitem><listitem><para><olink targetptr="bkupsavefiles-14144" remap="internal">How to Copy Directories
Between File Systems (cpio)</olink></para>
</listitem><listitem><para><olink targetptr="bkupsavefiles-22962" remap="internal">How to Copy Files to
a Tape (tar)</olink></para>
</listitem><listitem><para><olink targetptr="bkupsavefiles-18134" remap="internal">How to List the Files
on a Tape (tar)</olink></para>
</listitem><listitem><para><olink targetptr="bkupsavefiles-30917" remap="internal">How to Retrieve Files
From a Tape (tar)</olink></para>
</listitem><listitem><para><olink targetptr="bkupsavefiles-47" remap="internal">Copying Files to a Tape
With the pax Command</olink></para>
</listitem><listitem><para><olink targetptr="bkupsavefiles-85934" remap="internal">How to Copy All Files
in a Directory to a Tape (cpio)</olink></para>
</listitem><listitem><para><olink targetptr="bkupsavefiles-30690" remap="internal">How to List the Files
on a Tape (cpio)</olink></para>
</listitem><listitem><para><olink targetptr="bkupsavefiles-66148" remap="internal">How to Retrieve All
Files From a Tape (cpio)</olink></para>
</listitem><listitem><para><olink targetptr="bkupsavefiles-86108" remap="internal">How to Retrieve Specific
Files From a Tape (cpio)</olink></para>
</listitem><listitem><para><olink targetptr="bkupsavefiles-17981" remap="internal">How to Copy Files to
a Remote Tape Device (tar and dd)</olink></para>
</listitem><listitem><para><olink targetptr="bkupsavefiles-74428" remap="internal">How to Extract Files
From a Remote Tape Device</olink></para>
</listitem><listitem><para><olink targetptr="bkupsavefiles-84545" remap="internal">How to Copy Files to
a Single Formatted Diskette (tar)</olink></para>
</listitem><listitem><para><olink targetptr="bkupsavefiles-78890" remap="internal">How to List the Files
on a Diskette (tar)</olink></para>
</listitem><listitem><para><olink targetptr="bkupsavefiles-53640" remap="internal">How to Retrieve Files
From a Diskette (tar)</olink></para>
</listitem>
</itemizedlist>
</highlights><sect1 id="bkupsavefiles-1"><title>Commands for Copying File Systems</title><para>When you need to back up and restore complete file systems, use the <command>ufsdump</command> and <command>ufsrestore</command> commands described in <olink targetptr="bkupref-12756" remap="internal">Chapter&nbsp;27, UFS Backup and Restore Commands
(Reference)</olink>. When you want to copy or move individual files, portions
of file systems, or complete file systems, you can use the procedures described
in this chapter instead of the <command>ufsdump</command> and <command>ufsrestore</command> commands. </para><para>The following table describes when
to use the various backup commands.</para><table frame="topbot" id="bkupsavefiles-29175"><title>When to Use Various
Backup Commands</title><tgroup cols="3" colsep="0" rowsep="0"><colspec colname="column1" colwidth="129.80*"/><colspec colname="column2" colwidth="100.09*"/><colspec colname="column3" colwidth="129.11*"/><thead><row rowsep="1"><entry><para>Task</para>
</entry><entry><para>Command</para>
</entry><entry><para>For More Information</para>
</entry>
</row>
</thead><tbody><row><entry><para>Back up file systems to tape.</para>
</entry><entry><para><command>ufsdump</command></para>
</entry><entry><para><olink targetptr="bkuptasks2-34493" remap="internal">How to Back Up a File System to
Tape</olink></para>
</entry>
</row><row><entry><para>Create a file system snapshot.</para>
</entry><entry><para><command>fssnap</command></para>
</entry><entry><para><olink targetptr="bkupsnapshot-2" remap="internal">Chapter&nbsp;25, Using UFS Snapshots
(Tasks)</olink></para>
</entry>
</row><row><entry><para>Restore file systems from tape.</para>
</entry><entry><para><command>ufsrestore</command></para>
</entry><entry><para><olink targetptr="bkuprestoretasks-65439" remap="internal">How to Restore a Complete
File System</olink></para>
</entry>
</row><row><entry><para>Transport files to other systems.</para>
</entry><entry><para><command>pax</command>, <command>tar</command>, or <command>cpio</command></para>
</entry><entry><para><olink targetptr="bkupsavefiles-38276" remap="internal">Copying Files and File Systems
to Tape</olink></para>
</entry>
</row><row><entry><para>Copy files or file systems between disks.</para>
</entry><entry><para><command>dd</command></para>
</entry><entry><para><olink targetptr="bkupsavefiles-60904" remap="internal">How to Copy a Disk (dd)</olink></para>
</entry>
</row><row><entry><para>Copy files to diskette.</para>
</entry><entry><para><command>tar</command></para>
</entry><entry><para><olink targetptr="bkupsavefiles-84545" remap="internal">How to Copy Files to a Single
Formatted Diskette (tar)</olink></para>
</entry>
</row>
</tbody>
</tgroup>
</table><para>The following table describes various backup and restore commands.</para><table frame="topbot" id="bkupsavefiles-49795"><title>Summary of Various Backup
Commands</title><tgroup cols="4" colsep="0" rowsep="0"><colspec colname="column1" colwidth="115.73*"/><colspec colname="column2" colwidth="80.23*"/><colspec colname="column3" colwidth="81.82*"/><colspec colname="column4" colwidth="80.23*"/><thead><row rowsep="1"><entry><para>Command Name</para>
</entry><entry><para>Aware of File System Boundaries?</para>
</entry><entry><para>Supports Multiple Volume Backups?</para>
</entry><entry><para>Physical or Logical Copy?</para>
</entry>
</row>
</thead><tbody><row><entry><para><command>volcopy</command></para>
</entry><entry><para>Yes</para>
</entry><entry><para>Yes</para>
</entry><entry><para>Physical</para>
</entry>
</row><row><entry><para><command>tar</command></para>
</entry><entry><para>No</para>
</entry><entry><para>No</para>
</entry><entry><para>Logical</para>
</entry>
</row><row><entry><para><command>cpio</command></para>
</entry><entry><para>No</para>
</entry><entry><para>Yes</para>
</entry><entry><para>Logical</para>
</entry>
</row><row><entry><para><command>pax</command></para>
</entry><entry><para>Yes</para>
</entry><entry><para>Yes</para>
</entry><entry><para>Logical</para>
</entry>
</row><row><entry><para><command>dd</command></para>
</entry><entry><para>Yes</para>
</entry><entry><para>No</para>
</entry><entry><para>Physical</para>
</entry>
</row><row><entry><para><command>ufsdump/ufsrestore</command></para>
</entry><entry><para>Yes</para>
</entry><entry><para>Yes</para>
</entry><entry><para>Logical</para>
</entry>
</row><row><entry><para><command>fssnap</command></para>
</entry><entry><para>N/A</para>
</entry><entry><para>N/A</para>
</entry><entry><para>Logical</para>
</entry>
</row>
</tbody>
</tgroup>
</table><para>The following table describes the advantages and disadvantages of some
of these commands.</para><table frame="topbot" id="eypfg"><title>Advantages and Disadvantages of <command>tar</command>, <command>pax</command>, and <command>cpio</command> Commands</title><tgroup cols="4" colsep="0" rowsep="0"><colspec colname="column1" colwidth="64.55*"/><colspec colname="column2" colwidth="98.63*"/><colspec colname="column3" colwidth="98.62*"/><colspec colname="column4" colwidth="97.20*"/><thead><row rowsep="1"><entry><para>Command</para>
</entry><entry><para>Function</para>
</entry><entry><para>Advantages</para>
</entry><entry><para>Disadvantages</para>
</entry>
</row>
</thead><tbody><row><entry><para><command>tar</command></para>
</entry><entry><para>Use to copy files and directory subtrees to a single tape.</para>
</entry><entry><itemizedlist><listitem><para>Available on most UNIX operating systems</para>
</listitem><listitem><para>Public domain versions are readily available</para>
</listitem>
</itemizedlist>
</entry><entry><itemizedlist><listitem><para>Is not aware of file system boundaries</para>
</listitem><listitem><para>Length of full path name cannot exceed 255 characters</para>
</listitem><listitem><para>Cannot be used to create multiple tape volumes</para>
</listitem>
</itemizedlist>
</entry>
</row><row><entry><para><command>pax</command></para>
</entry><entry><para>Use to copy files, special files, or file systems that require multiple
tape volumes. Or, use when you want to copy files to and from POSIX-compliant
systems.</para>
</entry><entry><itemizedlist><listitem><para>Better portability than the <command>tar</command> or <command>cpio</command> commands for POSIX-compliant systems</para>
</listitem><listitem><para>Multiple vendor support</para>
</listitem>
</itemizedlist>
</entry><entry><para>Same disadvantages as the <command>tar</command> command, except that
the <command>pax</command> command can create multiple tape volumes.</para>
</entry>
</row><row><entry><para><command>cpio</command></para>
</entry><entry><para>Use to copy files, special files, or file systems that require multiple
tape volumes. Or, use when you want to copy files from systems running current
Solaris releases systems to systems running SunOS 4.0/4.1 releases.</para>
</entry><entry><itemizedlist><listitem><para>Packs data onto tape more efficiently than the <command>tar</command> command</para>
</listitem><listitem><para>Skips over any bad spots in a tape when restoring</para>
</listitem><listitem><para>Provides options for writing files with different header formats,
such as  ( <command>tar</command>, <command>ustar</command>, <command>crc</command>, <command>odc</command>, <command>bar</command>), for portability between different
system types</para>
</listitem><listitem><para>Creates multiple tape volumes</para>
</listitem>
</itemizedlist>
</entry><entry><para>The command syntax is more difficult than the <command>tar</command> or <command>pax</command> commands.</para>
</entry>
</row>
</tbody>
</tgroup>
</table><para>The following sections describes step-by-step instructions and examples
of how to use these commands.</para>
</sect1><sect1 id="bkupsavefiles-2"><title>Copying File Systems Between Disks</title><para>Two commands are used to copy file systems between disks:</para><itemizedlist><listitem><para><command>volcopy</command></para>
</listitem><listitem><para><command>dd</command></para>
</listitem>
</itemizedlist><para>For more information about <command>volcopy</command>, see <olink targetdoc="refman1m" targetptr="volcopy-1m" remap="external"><citerefentry><refentrytitle>volcopy</refentrytitle><manvolnum>1M</manvolnum></citerefentry></olink>.</para><para>The next section describes how to use the <command>dd</command> command
to copy file systems between disks.</para><sect2 id="bkupsavefiles-3"><title>Making a Literal File System Copy</title><para>The <command>dd</command> command
makes a literal (block-level) copy of a complete UFS file system to another
file system or to a tape. By default, the <command>dd</command> command copies
standard input to standard output.   </para><note><para>Do not use the <command>dd</command> command with variable-length
tape drives without first specifying an appropriate block size.</para>
</note><para>You can specify a device name in place of standard input or standard
output, or both. In this example, the contents of the diskette are copied
to a file in the <filename>/tmp</filename> directory:</para><screen>$ <userinput>dd &lt; /floppy/floppy0 > /tmp/output.file</userinput>
2400+0 records in
2400+0 records out</screen><para>The <command>dd</command> command reports on the number of blocks it
reads and writes. The number after the <filename>+</filename> is a count of
the partial blocks that were copied. The default block size is 512 bytes.</para><para>The <command>dd</command> command syntax is different from most other
commands. Options are specified as <replaceable>keyword</replaceable>=<replaceable>value</replaceable> pairs, where <replaceable>keyword</replaceable> is the
option you want to set and <replaceable>value</replaceable> is the argument
for that option. For example, you can replace standard input and standard
output with this syntax: </para><screen>$ <userinput>dd if=</userinput><replaceable>input-file</replaceable> <userinput>of=</userinput><replaceable>output-file</replaceable></screen><para>To use the <replaceable>keyword</replaceable>=<replaceable>value</replaceable> pairs
instead of the redirect symbols, you would type the following:</para><screen>$ <userinput>dd if=/floppy/floppy0 of=/tmp/output.file</userinput></screen>
</sect2><task id="bkupsavefiles-60904"><title>How to Copy a Disk (<command>dd</command>)</title><tasksummary><para>Keep the following key points in mind when you consider copying a disk:</para><itemizedlist><listitem><para>Do not use this procedure to copy a disk that is under the
control of a volume manager.</para>
</listitem><listitem><para>The primary methods for copying UFS file system data from
one disk or system to another disk or system is by using the <command>ufsdump</command> and <command>ufsrestore</command> commands. For more information on using these commands,
see <olink targetptr="bkupconcepts-57422" remap="internal">Chapter&nbsp;23, Backing Up and
Restoring File Systems (Overview)</olink>.</para>
</listitem><listitem><para>You can clone systems by creating a flash archive and copying
it to destination systems. For more information about creating a flash archive,
see <olink targetdoc="solinstallflash" remap="external"><citetitle remap="book">Solaris Express Installation Guide: Solaris Flash Archives (Creation and Installation)</citetitle></olink>.</para>
</listitem><listitem><para>If you are copying a disk with an EFI disk label, see <olink targetptr="fpyma" remap="internal">Example&nbsp;28&ndash;2</olink>.</para>
</listitem>
</itemizedlist><para>If you are still considering copying a disk with the <command>dd</command> command
keep the following cautions in mind:</para><itemizedlist><listitem><para>Make sure that the source disk and destination disk have the
same disk geometry.</para>
</listitem><listitem><para>Check the UFS file systems on the disk to be copied with the <command>fsck</command> utility.</para>
</listitem><listitem><para>Make sure the system is in single-user mode when copying a
disk with the <command>dd</command> command.</para>
</listitem>
</itemizedlist>
</tasksummary><procedure><step id="bkupsavefiles-step-6"><para>Become superuser or assume an equivalent
role.</para>
</step><step id="bkupsavefiles-step-8"><para>Shut down the system.</para><screen># <userinput>init 0</userinput></screen>
</step><step id="bkupsavefiles-step-9"><para>Attach the destination disk to the system.</para>
</step><step id="bkupsavefiles-step-10"><para>Boot the system.</para><screen>ok <userinput>boot -s</userinput></screen>
</step><step id="bkupsavefiles-step-11"><para>Copy the source disk to the destination disk. </para><screen># <userinput>dd if=/dev/rdsk/</userinput><replaceable>device-name</replaceable> <userinput>of=/dev/rdsk/</userinput><replaceable>device-name</replaceable> <userinput>bs=</userinput><replaceable>block-size</replaceable></screen><variablelist><varlistentry><term><filename>if=/dev/rdsk/</filename><replaceable>device-name</replaceable></term><listitem><para>Represents the overlap slice of the master disk device, usually
slice 2.</para>
</listitem>
</varlistentry><varlistentry><term><filename>of=/dev/rdsk/</filename><replaceable>device-name</replaceable></term><listitem><para>Represents the overlap slice of the destination disk device,
usually slice 2.</para>
</listitem>
</varlistentry><varlistentry><term><command>bs=</command><replaceable>blocksize</replaceable></term><listitem><para>Identifies the block size, such as 128 Kbytes or 256 Kbytes.
A large block size decreases the time it takes to copy the disk.</para>
</listitem>
</varlistentry>
</variablelist><para>For more information, see <olink targetdoc="refman1m" targetptr="dd-1m" remap="external"><citerefentry><refentrytitle>dd</refentrytitle><manvolnum>1M</manvolnum></citerefentry></olink>.</para>
</step><step id="bkupsavefiles-step-114"><para>Check the new file system.</para><screen># <userinput>fsck /dev/rdsk/</userinput><replaceable>device-name</replaceable></screen>
</step><step id="bkupsavefiles-step-12"><para>Mount the destination disk's root (<filename>/</filename>) file system.</para><screen># <userinput>mount /dev/dsk/</userinput><replaceable>device-name</replaceable> <userinput>/mnt</userinput></screen>
</step><step><para>Change to the directory where the <filename>/etc/vfstab</filename> file
is located.</para><screen># <userinput>cd /mnt/etc</userinput></screen>
</step><step id="bkupsavefiles-step-13"><para>Using a text editor, edit the destination
disk's <filename>/etc/vfstab</filename> file to reference the correct device
names.</para><para>For example, change all instances of <literal>c0t3d0</literal> to <literal>c0t1d0</literal>.</para>
</step><step><para>Change to the destination disk's root (<filename>/</filename>)
directory.</para><screen># <userinput>cd /</userinput></screen>
</step><step id="bkupsavefiles-step-14"><para>Unmount the destination disk's root
(<filename>/</filename>) file system.</para><screen># <userinput>umount /mnt</userinput></screen>
</step><step id="bkupsavefiles-step-15"><para>Shut down the system.</para><screen># <userinput>init 0</userinput></screen>
</step><step id="bkupsavefiles-step-16"><para>Boot from the destination disk to single-user
mode.</para><screen># <userinput>boot disk</userinput><replaceable>n</replaceable> <userinput>-s</userinput></screen><note><para>The <command>installboot</command> command is not needed for the
destination disk because the boot blocks are copied as part of the overlap
slice.</para>
</note>
</step><step id="bkupsavefiles-step-17"><para>Unconfigure the destination disk.</para><screen># <userinput>sys-unconfig</userinput></screen><para>The system is shut down after it is unconfigured.</para>
</step><step id="bkupsavefiles-step-18"><para>Boot from the destination disk again
and provide its system information, such as host name, time zone, and so forth. </para><screen># <userinput>boot disk</userinput><replaceable>n</replaceable></screen>
</step><step id="bkupsavefiles-step-115"><para>After the system is booted, log in
as superuser to verify the system information.</para><screen><replaceable>hostname</replaceable> console login:</screen>
</step>
</procedure><example id="fncrt"><title>Copying a Disk With a VTOC Label (<command>dd</command>)</title><para>This example shows how to copy the master disk (with a VTOC label) <literal>/dev/rdsk/c0t0d0s2</literal> to the destination disk <literal>/dev/rdsk/c0t2d0s2</literal>.</para><screen># <userinput>init 0</userinput>
ok <userinput>boot</userinput>
# <userinput>dd if=/dev/rdsk/c0t0d0s2 of=/dev/rdsk/c0t2d0s2</userinput> <userinput>bs=128k</userinput>
# <userinput>fsck /dev/rdsk/c0t2d0s2</userinput>
# <userinput>mount /dev/dsk/c0t2d0s2 /mnt</userinput> 
# <userinput>cd /mnt/etc</userinput>
# <userinput>vi vfstab</userinput>
(<replaceable>Modify entries for the new disk</replaceable>)
# <userinput>cd /</userinput>
# <userinput>umount /mnt</userinput>
# <userinput>init 0</userinput>
# <userinput>boot disk2 -s</userinput>
# <userinput>sys-unconfig</userinput>
# <userinput>boot disk2</userinput></screen>
</example><example id="fpyma"><title>Copying a Disk with an EFI Label (<command>dd</command>)</title><para>In previous Solaris releases, slice 2 (<literal>s2</literal>) was used
to represent the entire disk. On a disk with an EFI label, you must use a
slightly different procedure to clone or copy disks larger than 1 terabyte
so that the UUID of cloned disks is unique. If you do not create a new label
for the cloned disk, other software products might corrupt data on EFI-labeled
disks if they encounter duplicate UUIDs.</para><para>For example:</para><orderedlist><listitem><para>Clone the disk with an EFI label. For example:</para><screen># <userinput>dd if=/dev/rdsk/c0t0d0 of=/dev/rdsk/c0t2d0 bs=128k</userinput></screen>
</listitem><listitem><para>Pipe the <command>prtvtoc</command> output of the disk to
be copied to the <command>fmthard</command> command to create a new label
for the cloned disk. For example:</para><screen># <userinput>prtvtoc /dev/rdsk/c0t0d0 | fmthard -s - /dev/rdsk/c0t2d0</userinput></screen>
</listitem>
</orderedlist><para>For more information about EFI disk labels, see <olink targetptr="disksconcepts-14" remap="internal">EFI Disk Label</olink>.</para>
</example>
</task>
</sect1><sect1 id="bkupsavefiles-21"><title>Copying Directories Between File Systems
(<command>cpio</command> Command)</title><para>You can use the <command>cpio</command> (copy in and out) command to
copy individual files, groups of files, or complete file systems. This section
describes how to use the <command>cpio</command> command to copy complete
file systems.</para><para>The <command>cpio</command> command is an archiving program that copies
a list of files into a single, large output file. This command inserts headers
between the individual files to facilitate recovery. You can use the <command>cpio</command> command to copy complete file systems to another slice, another
system, or to a media device, such as a tape or diskette.</para><para>Because the <command>cpio</command> command recognizes end-of-media
and prompts you to insert another volume, it is the most effective command,
 other than <command>ufsdump</command>, to use to create archives that require
multiple tapes or diskettes.</para><para>With the <command>cpio</command> command, you frequently use the  <command>ls</command> and <command>find</command> commands to list and select the files
you want to copy, and then to pipe the output to the <command>cpio</command> command.</para><task id="bkupsavefiles-14144"><title>How to Copy Directories Between File
Systems (<command>cpio</command>)</title><procedure><step id="bkupsavefiles-step-23"><para>Become superuser or assume an equivalent
role.</para>
</step><step id="bkupsavefiles-step-24"><para>Change to the appropriate directory.</para><screen># <userinput>cd</userinput> <replaceable>filesystem1</replaceable></screen>
</step><step id="bkupsavefiles-step-25"><para>Copy the directory tree
from <replaceable>filesystem1</replaceable> to <replaceable>filesystem2</replaceable> by
using a combination of the <command>find</command> and <command>cpio</command> commands. </para><screen># <userinput>find . -print -depth | cpio -pdm</userinput> <replaceable>filesystem2</replaceable></screen><variablelist><varlistentry><term>.</term><listitem><para>Starts in the current working directory.</para>
</listitem>
</varlistentry><varlistentry><term><option>print</option></term><listitem><para>Prints the file names.</para>
</listitem>
</varlistentry><varlistentry><term><option>depth</option></term><listitem><para>Descends the directory hierarchy and prints file names from
the bottom up.</para>
</listitem>
</varlistentry><varlistentry><term><option>p</option></term><listitem><para>Creates a list of files.</para>
</listitem>
</varlistentry><varlistentry><term><option>d</option></term><listitem><para>Creates directories as needed.</para>
</listitem>
</varlistentry><varlistentry><term><option>m</option></term><listitem><para>Sets the correct modification times on directories.</para>
</listitem>
</varlistentry>
</variablelist><para>For more information, see <olink targetdoc="refman1" targetptr="cpio-1" remap="external"><citerefentry><refentrytitle>cpio</refentrytitle><manvolnum>1</manvolnum></citerefentry></olink>.</para><para>The files from the directory name you specify are copied. The
symbolic links are preserved.</para><para>You might also specify the <option>u</option> option.
This option forces an unconditional copy. Otherwise, older files do not replace
newer files. This option might be useful if you want an exact copy of a directory,
and some of the files being copied might already exist in the target directory. </para>
</step><step id="bkupsavefiles-step-125"><para>Verify that the copy was successful
by displaying the contents of the destination directory.</para><screen># <userinput>cd</userinput> <replaceable>filesystem2</replaceable>
# <userinput>ls</userinput></screen>
</step><step id="bkupsavefiles-step-26"><para>If appropriate, remove the source directory.</para><screen># <userinput>rm -rf</userinput> <replaceable>filesystem1</replaceable></screen>
</step>
</procedure><example id="fncsb"><title>Copying Directories Between File Systems (<command>cpio</command>)</title><screen># <userinput>cd /data1</userinput>
# <userinput>find . -print -depth | cpio -pdm /data2</userinput>
19013 blocks
# <userinput>cd /data2</userinput>
# <userinput>ls</userinput>
# <userinput>rm -rf /data1</userinput></screen>
</example>
</task>
</sect1><sect1 id="bkupsavefiles-38276"><title>Copying Files and File Systems to Tape</title><para>You can use the <command>tar</command>, <command>pax</command>, and <command>cpio</command> commands to copy files and file systems to tape. The command
that you choose depends on how much flexibility and precision you require
for the copy. Because all three commands use the raw device, you do not need
to format or make a file system on tapes before you use them.</para><para>The tape drive and device name that you use depend on the hardware configuration
for each system. For more information about tape device names, see <olink targetptr="bkuptapedevice-26951" remap="internal">Choosing Which Media to Use</olink>.</para>
</sect1><sect1 id="bkupsavefiles-30"><title>Copying Files to Tape (<command>tar</command> Command)</title><para>Here is information that you should know before you copy files to tape
with the <command>tar</command> command:</para><itemizedlist><listitem><para>Copying files to a tape with the <option>c</option> option
to the <command>tar</command> command destroys any files already on the tape
at or beyond the current tape position.</para>
</listitem><listitem><para>You can use file name substitution wildcards (<filename>?</filename> and <filename>*</filename>) as part of the file names that you specify when copying files.
For example, to copy all documents with a <filename>.doc</filename> suffix,
type <filename>*.doc</filename> as the file name argument.</para>
</listitem><listitem><para>You cannot use file name substitution wildcards when you extract
files from a <command>tar</command> archive.</para>
</listitem>
</itemizedlist><task id="bkupsavefiles-22962"><title>How to Copy Files to a Tape (<command>tar</command>)</title><procedure><step id="bkupsavefiles-step-32"><para>Change to the directory that contains
the files you want to copy.</para>
</step><step id="bkupsavefiles-step-33"><para>Insert a write-enabled tape into the
tape drive.</para>
</step><step id="bkupsavefiles-step-34"><para>Copy the files to tape. </para><screen>$ <userinput>tar cvf /dev/rmt/</userinput><replaceable>n</replaceable> <replaceable>filenames</replaceable></screen><variablelist><varlistentry><term><command>c</command></term><listitem><para>Indicates that you want to create an archive.</para>
</listitem>
</varlistentry><varlistentry><term><command>v</command></term><listitem><para>Displays the name of each file as it is archived.</para>
</listitem>
</varlistentry><varlistentry><term><command>f</command> <filename>/dev/rmt/</filename><replaceable>n</replaceable></term><listitem><para>Indicates that the archive should be written to the specified
device or file.</para>
</listitem>
</varlistentry><varlistentry><term><replaceable>filenames</replaceable></term><listitem><para>Indicates the files and directories that you want to copy.
Separate multiple files with spaces.</para>
</listitem>
</varlistentry>
</variablelist><para>The file names that you specify are copied to the tape, overwriting
any existing files on the tape.</para>
</step><step id="bkupsavefiles-step-35"><para>Remove the tape from the drive. Write
the names of the files on the tape label.</para>
</step><step id="bkupsavefiles-step-116"><para>Verify that the files you copied are
on the tape.</para><screen>$ <userinput>tar tvf /dev/rmt/</userinput><replaceable>n</replaceable></screen><para>For more information on listing files on a <command>tar</command> tape,
see <olink targetptr="bkupsavefiles-18134" remap="internal">How to List the Files on a Tape
(tar)</olink>.</para>
</step>
</procedure><example id="fncse"><title>Copying Files to a Tape (<command>tar</command>)</title><para>The following example shows how to copy three files to the tape in tape
drive 0.</para><screen>$ <userinput>cd /export/home/kryten</userinput>
$ <userinput>ls reports</userinput>
reportA reportB reportC
$ <userinput>tar cvf /dev/rmt/0 reports</userinput>
a reports/ 0 tape blocks
a reports/reportA 59 tape blocks
a reports/reportB 61 tape blocks
a reports/reportC 63 tape blocks
$ <userinput>tar tvf /dev/rmt/0</userinput></screen>
</example>
</task><task id="bkupsavefiles-18134"><title>How to List the Files on a Tape (<command>tar</command>)</title><procedure><step id="bkupsavefiles-step-39"><para>Insert a tape into the tape drive.</para>
</step><step id="bkupsavefiles-step-40"><para>Display the tape contents. </para><screen>$ <userinput>tar tvf /dev/rmt/</userinput><replaceable>n</replaceable></screen><variablelist><varlistentry><term><command>t</command></term><listitem><para>Lists the table of contents for the files on the tape.</para>
</listitem>
</varlistentry><varlistentry><term><command>v</command></term><listitem><para>Used with the <command>t</command> option, and provides detailed
information about the files on the tape.</para>
</listitem>
</varlistentry><varlistentry><term><filename>f /dev/rmt/</filename><replaceable>n</replaceable></term><listitem><para>Indicates the tape device.</para>
</listitem>
</varlistentry>
</variablelist>
</step>
</procedure><example id="fncru"><title>Listing the Files on a Tape (<command>tar</command>)</title><para>The following example shows a listing of files on the tape in drive
0.</para><screen>$ <userinput>tar tvf /dev/rmt/0</userinput>
drwxr-xr-x   0/1        0 Jul 28 15:00 2004 reports/
-r--r--r--   0/1   206663 Jul 28 15:00 2004 reports/reportA
-r--r--r--   0/1   206663 Jul 28 15:00 2004 reports/reportB
-r--r--r--   0/1   206663 Jul 28 15:00 2004 reports/reportC</screen>
</example>
</task><task id="bkupsavefiles-30917"><title>How to Retrieve Files From a Tape (<command>tar</command>)</title><procedure><step id="bkupsavefiles-step-43"><para>Change to the directory where you want to
put the files.</para>
</step><step id="bkupsavefiles-step-44"><para>Insert the tape into the tape drive.</para>
</step><step id="bkupsavefiles-step-45"><para>Retrieve the files from the tape. </para><screen>$ <userinput>tar xvf /dev/rmt/</userinput><replaceable>n</replaceable> [<replaceable>filenames</replaceable>]</screen><variablelist><varlistentry><term><command>x</command></term><listitem><para>Indicates that the files should be extracted from the specified
archive file. All files on the tape in the specified drive are copied to the
current directory.</para>
</listitem>
</varlistentry><varlistentry><term><command>v</command></term><listitem><para>Displays the name of each file as it is retrieved.</para>
</listitem>
</varlistentry><varlistentry><term><command>f</command> <filename>/dev/rmt/</filename><replaceable>n</replaceable></term><listitem><para>Indicates the tape device that contains the archive.</para>
</listitem>
</varlistentry><varlistentry><term><replaceable>filenames</replaceable></term><listitem><para>Specifies a file to retrieve. Separate multiple files with
spaces.</para>
</listitem>
</varlistentry>
</variablelist><para>For more information, see the <olink targetdoc="refman1" targetptr="tar-1" remap="external"><citerefentry><refentrytitle>tar</refentrytitle><manvolnum>1</manvolnum></citerefentry></olink> man
page.</para>
</step><step id="bkupsavefiles-step-117"><para>Verify that the files have been copied.</para><screen>$ <userinput>ls -l</userinput></screen>
</step>
</procedure><example id="fncsk"><title>Retrieving Files on a Tape (<command>tar</command>)</title><para>The following example shows how to retrieve all the files from the tape
in drive 0.</para><screen>$ <userinput>cd /var/tmp</userinput>
$ <userinput>tar xvf /dev/rmt/0</userinput>
x reports/, 0 bytes, 0 tape blocks
x reports/reportA, 0 bytes, 0 tape blocks
x reports/reportB, 0 bytes, 0 tape blocks
x reports/reportC, 0 bytes, 0 tape blocks
x reports/reportD, 0 bytes, 0 tape blocks
$ <userinput>ls -l</userinput></screen>
</example><taskrelated role="troubleshooting"><para>The names of the files extracted from the tape must exactly match the
names of the files that are stored on the archive. If you have any doubts
about the names or paths of the files, first list the files on the tape. For
instructions on listing the files on the tape, see <olink targetptr="bkupsavefiles-18134" remap="internal">How to List the Files on a Tape (tar)</olink>.</para>
</taskrelated>
</task>
</sect1><sect1 id="bkupsavefiles-47"><title>Copying Files to a Tape With the <command>pax</command> Command</title><task id="bkupsavefiles-48"><title>How to Copy Files to a Tape (<command>pax</command>)</title><procedure><step id="bkupsavefiles-step-50"><para>Change to the directory that contains
the files you want to copy.</para>
</step><step id="bkupsavefiles-step-51"><para>Insert a write-enabled tape into the
tape drive.</para>
</step><step id="bkupsavefiles-step-52"><para>Copy the files to tape.</para><screen>$ <userinput>pax -w -f /dev/rmt/<replaceable>n</replaceable></userinput> <replaceable>filenames</replaceable></screen><variablelist><varlistentry><term><command>-w</command></term><listitem><para>Enables the write mode.</para>
</listitem>
</varlistentry><varlistentry><term><command>-f /dev/rmt/<replaceable>n</replaceable></command></term><listitem><para>Identifies the tape drive.</para>
</listitem>
</varlistentry><varlistentry><term><replaceable>filenames</replaceable></term><listitem><para>Indicates the files and directories that you want to copy.
Separate multiple files with spaces.</para>
</listitem>
</varlistentry>
</variablelist><para>For more information, see the <olink targetdoc="refman1" targetptr="pax-1" remap="external"><citerefentry><refentrytitle>pax</refentrytitle><manvolnum>1</manvolnum></citerefentry></olink> man
page.</para>
</step><step id="bkupsavefiles-step-118"><para>Verify that the files have been copied
to tape.</para><screen>$ <userinput>pax -f /dev/rmt/<replaceable>n</replaceable></userinput></screen>
</step><step id="bkupsavefiles-step-53"><para>Remove the tape from the drive. Write
the names of the files on the tape label.</para>
</step>
</procedure><example id="fncry"><title>Copying Files to a Tape (<command>pax</command>)</title><para>The following example shows how to use the <command>pax</command> command
to copy all the files in the current directory.</para><screen>$ <userinput>pax -w -f /dev/rmt/0 .</userinput>
$ <userinput>pax -f /dev/rmt/0</userinput>
filea fileb filec</screen>
</example>
</task>
</sect1><sect1 id="bkupsavefiles-129"><title>Copying Files to Tape With the <command>cpio</command> Command</title><task id="bkupsavefiles-85934"><title>How to Copy All Files in a Directory
to a Tape (<command>cpio</command>)</title><procedure><step id="bkupsavefiles-step-1"><para>Change to the directory that contains
the files you want to copy.</para>
</step><step id="bkupsavefiles-step-57"><para>Insert a write-enabled tape into the
tape drive.</para>
</step><step id="bkupsavefiles-step-58"><para>Copy the files to tape.</para><screen>$ <userinput>ls | cpio -oc > /dev/rmt/</userinput><replaceable>n</replaceable></screen><variablelist><varlistentry><term><command>ls</command></term><listitem><para>Provides the <command>cpio</command> command with a list of
file names.</para>
</listitem>
</varlistentry><varlistentry><term><command>cpio -oc</command></term><listitem><para>Specifies that the <filename>cpio</filename> command should
operate in copy-out mode  (<option>o</option>) and write header information
in ASCII character format (<option>c</option>). These options ensure portability
to other vendors' systems.</para>
</listitem>
</varlistentry><varlistentry><term><command>> /dev/rmt/</command><replaceable>n</replaceable></term><listitem><para>Specifies the output file.</para>
</listitem>
</varlistentry>
</variablelist><para>All files in the directory are copied to the tape in the drive you specify,
overwriting any existing files on the tape. The total number of blocks that
are copied is shown.</para>
</step><step id="bkupsavefiles-step-119"><para>Verify that the files have been copied
to tape.</para><screen>$ <userinput>cpio -civt &lt; /dev/rmt/</userinput><replaceable>n</replaceable></screen><variablelist><varlistentry><term><option>c</option></term><listitem><para>Specifies that the <command>cpio</command> command should
read files in ASCII character format.</para>
</listitem>
</varlistentry><varlistentry><term><option>i</option></term><listitem><para>Specifies that the <command>cpio</command> command should
operate in copy-in mode, even though the command is only listing files at
this point.</para>
</listitem>
</varlistentry><varlistentry><term><option>v</option></term><listitem><para>Displays the output in a format that is similar to the output
from the <command>ls -l</command> command.</para>
</listitem>
</varlistentry><varlistentry><term><option>t</option></term><listitem><para>Lists the table of contents for the files on the tape in the
tape drive that you specify.</para>
</listitem>
</varlistentry><varlistentry><term><filename>&lt; /dev/rmt/</filename><replaceable>n</replaceable></term><listitem><para>Specifies the input file of an existing <command>cpio</command> archive.</para>
</listitem>
</varlistentry>
</variablelist>
</step><step id="bkupsavefiles-step-59"><para>Remove the tape from the drive. Write
the names of the files on the tape label.</para>
</step>
</procedure><example id="fncrz"><title>Copying All Files in a Directory to a Tape (<command>cpio</command>)</title><para>The following example shows how to copy all of the files in the <filename>/export/home/kryten</filename> directory to the tape in tape drive 0.</para><screen>$ <userinput>cd /export/home/kryten</userinput>
$ <userinput>ls | cpio -oc > /dev/rmt/0</userinput>
16 blocks
$ <userinput>cpio -civt &lt; /dev/rmt/0</userinput>
-rw-r--r--    1 root     other          0 Jul 28 14:59 2004, filea
-rw-r--r--    1 root     other          0 Jul 28 14:59 2004, fileb
-rw-r--r--    1 root     other          0 Jul 28 14:59 2004, filec
drwxr-xr-x    2 root     other          0 Jul 28 14:59 2004, letters
drwxr-xr-x    2 root     other          0 Jul 28 15:00 2004, reports
16 blocks
$</screen>
</example>
</task><task id="bkupsavefiles-30690"><title>How to List the Files on a Tape (<command>cpio</command>)</title><tasksummary><note><para>Listing the table of contents on a tape takes a long time because
the <command>cpio</command> command must process the entire archive.</para>
</note>
</tasksummary><procedure><step id="bkupsavefiles-step-63"><para>Insert an archive tape into the tape
drive.</para>
</step><step id="bkupsavefiles-step-64"><para>List the files on the tape. </para><screen>$ <userinput>cpio -civt &lt; /dev/rmt/</userinput><replaceable>n</replaceable></screen>
</step>
</procedure><example id="fncsi"><title>Listing the Files on a Tape (<command>cpio</command>)</title><para>The following example shows how to list the files on the tape in drive
0.</para><screen>$ <userinput>cpio -civt &lt; /dev/rmt/0</userinput>
-rw-r--r--    1 root     other          0 Jul 28 14:59 2004, filea
-rw-r--r--    1 root     other          0 Jul 28 14:59 2004, fileb
-rw-r--r--    1 root     other          0 Jul 28 14:59 2004, filec
drwxr-xr-x    2 root     other          0 Jul 28 14:59 2004, letters
drwxr-xr-x    2 root     other          0 Jul 28 15:00 2004, reports
16 blocks
$</screen>
</example>
</task><task id="bkupsavefiles-66148"><title>How to Retrieve All Files From a Tape
(<command>cpio</command>)</title><tasksummary><para>If the archive was created using relative path names, the input files
are built as a directory within the current directory when you retrieve the
files. If, however, the archive was created with absolute path names, the
same absolute paths are used to re-create the file on your system.</para><caution><para>The use of absolute path names can be dangerous because you
might overwrite existing files on your system.</para>
</caution>
</tasksummary><procedure><step id="bkupsavefiles-step-67"><para>Change to the directory where you want
to put the files.</para>
</step><step id="bkupsavefiles-step-68"><para>Insert the tape into the tape drive.</para>
</step><step id="bkupsavefiles-step-69"><para>Extract all files from the tape. </para><screen>$ <userinput>cpio -icvd &lt; /dev/rmt/</userinput><replaceable>n</replaceable></screen><variablelist><varlistentry><term><option>i</option></term><listitem><para>Extracts files from standard input.</para>
</listitem>
</varlistentry><varlistentry><term><option>c</option></term><listitem><para>Specifies that the <command>cpio</command> command should
read files in ASCII character format.</para>
</listitem>
</varlistentry><varlistentry><term><option>v</option></term><listitem><para>Displays the files as they are retrieved in a format that
is similar to the output from the <command>ls</command> command.</para>
</listitem>
</varlistentry><varlistentry><term><option>d</option></term><listitem><para>Creates directories as needed.</para>
</listitem>
</varlistentry><varlistentry><term><filename>&lt; /dev/rmt/</filename><replaceable>n</replaceable></term><listitem><para>Specifies the output file.</para>
</listitem>
</varlistentry>
</variablelist>
</step><step id="bkupsavefiles-step-120"><para>Verify that the files were copied.</para><screen>$ <userinput>ls -l</userinput></screen>
</step>
</procedure><example id="fncsc"><title>Retrieving All Files From a Tape (<command>cpio</command>)</title><para>The following example shows how to retrieve all files from the tape
in drive 0.</para><screen>$ <userinput>cd /var/tmp</userinput>
<userinput>cpio -icvd &lt; /dev/rmt/0</userinput>
answers 
sc.directives 
tests
8 blocks
$ <userinput>ls -l</userinput></screen>
</example>
</task><task id="bkupsavefiles-86108"><title>How to Retrieve Specific Files From
a Tape (<command>cpio</command>)</title><procedure><step id="bkupsavefiles-step-72"><para>Change to the directory where you want
to put the files.</para>
</step><step id="bkupsavefiles-step-73"><para>Insert the tape into the tape drive.</para>
</step><step id="bkupsavefiles-step-74"><para>Retrieve a subset of files from the
tape.</para><screen>$ <userinput>cpio -icv "</userinput><replaceable>*file</replaceable><userinput>" &lt; /dev/rmt/</userinput><replaceable>n</replaceable></screen><variablelist><varlistentry><term><option>i</option></term><listitem><para>Extracts files from standard input.</para>
</listitem>
</varlistentry><varlistentry><term><option>c</option></term><listitem><para>Specifies that the <command>cpio</command> command should
read headers in ASCII character format.</para>
</listitem>
</varlistentry><varlistentry><term><option>v</option></term><listitem><para>Displays the files as they are retrieved in a format that
is similar to the output from the <command>ls</command> command.</para>
</listitem>
</varlistentry><varlistentry><term><command>"*</command><replaceable>file</replaceable><command>"</command></term><listitem><para>Specifies that all files that match the pattern are copied
to the current directory. You can specify multiple patterns, but each pattern
must be enclosed in double quotation marks.</para>
</listitem>
</varlistentry><varlistentry><term><filename>&lt; /dev/rmt/</filename><replaceable>n</replaceable></term><listitem><para>Specifies the input file.</para>
</listitem>
</varlistentry>
</variablelist><para>For more information, see the <olink targetdoc="refman1" targetptr="cpio-1" remap="external"><citerefentry><refentrytitle>cpio</refentrytitle><manvolnum>1</manvolnum></citerefentry></olink> man
page.</para>
</step><step id="bkupsavefiles-step-126"><para>Verify that the files were copied.</para><screen>$ <userinput>ls -l</userinput></screen>
</step>
</procedure><example id="fncrv"><title>Retrieving Specific Files From a Tape (<command>cpio</command>)</title><para>The following example shows how to retrieve all files with the <filename>chapter</filename> suffix from the tape in drive 0.</para><screen>$ <userinput>cd /home/smith/Book</userinput>
$ <userinput>cpio -icv "*chapter" &lt; /dev/rmt/0</userinput>
Boot.chapter 
Directory.chapter 
Install.chapter 
Intro.chapter
31 blocks
$ <userinput>ls -l</userinput></screen>
</example>
</task>
</sect1><sect1 id="bkupsavefiles-130"><title>Copying Files to a Remote Tape Device</title><task id="bkupsavefiles-17981"><title>How to Copy Files to a Remote Tape Device
(<command>tar</command> and <command>dd</command>)</title><procedure><step id="bkupsavefiles-step-77"><para>The following prerequisites must be
met to use a remote tape drive:</para><substeps><step id="bkupsavefiles-step-128"><para>The local host name and optionally,
the user name of the user doing the copy, must appear in the remote system's <filename>/etc/hosts.equiv</filename> file. Or, the user doing the copy must have his
or her home directory accessible on the remote machine, and have the local
machine name in <filename>$HOME/.rhosts</filename>.</para><para>For more information,
see the <olink targetdoc="refman4" targetptr="hosts.equiv-4" remap="external"><citerefentry><refentrytitle>hosts.equiv</refentrytitle><manvolnum>4</manvolnum></citerefentry></olink> man page.</para>
</step><step id="bkupsavefiles-step-127"><para>An entry for the remote system must
be in the local system's <filename>/etc/inet/hosts</filename> file or in the
name service <filename>hosts</filename> file.</para>
</step>
</substeps>
</step><step id="bkupsavefiles-step-121"><para>To test whether you have the appropriate
permission to execute a remote command, try the following:</para><screen>$ <userinput>rsh remotehost echo test</userinput></screen><para>If <literal>test</literal> is echoed back to you, you have permission
to execute remote commands. If <literal>Permission denied</literal> is echoed
back to you, check your setup as described in Step 1.</para>
</step><step id="bkupsavefiles-step-2"><para>Change to the directory where you want
to put the files.</para>
</step><step id="bkupsavefiles-step-3"><para>Insert the tape into the tape drive.</para>
</step><step id="bkupsavefiles-step-78"><para>Copy the files to a remote tape drive. </para><screen>$ <userinput>tar cvf -</userinput> <replaceable>filenames</replaceable> <userinput>| rsh</userinput> <replaceable>remote-host</replaceable> <userinput>dd of=/dev/rmt/</userinput><replaceable>n</replaceable> <userinput>obs=</userinput><replaceable>block-size</replaceable></screen><variablelist><varlistentry><term><command>tar</command> <command>cf</command></term><listitem><para>Creates a tape archive, lists the files as they are archived,
and specifies the tape device.</para>
</listitem>
</varlistentry><varlistentry><term><command>v</command></term><listitem><para>Provides additional information about the tar file entries.</para>
</listitem>
</varlistentry><varlistentry><term><command>-</command> (Hyphen)</term><listitem><para>Represents a placeholder for the tape device.</para>
</listitem>
</varlistentry><varlistentry><term><replaceable>filenames</replaceable></term><listitem><para>Identifies the files to be copied. Separate multiple files
with spaces.</para>
</listitem>
</varlistentry><varlistentry><term><command>rsh</command> <replaceable>| remote-host</replaceable></term><listitem><para>Pipes the <command>tar</command> command's output to a remote
shell.</para>
</listitem>
</varlistentry><varlistentry><term><command>dd of=</command> /dev/rmt<replaceable>/n</replaceable></term><listitem><para>Represents the output device.</para>
</listitem>
</varlistentry><varlistentry><term><command>obs=</command><replaceable>block-size</replaceable></term><listitem><para>Represents the blocking factor.</para>
</listitem>
</varlistentry>
</variablelist>
</step><step id="bkupsavefiles-step-79"><para>Remove the tape from the drive. Write
the names of the files on the tape label.</para>
</step>
</procedure><example id="fncsh"><title>Copying Files to a Remote Tape Drive (<command>tar</command> and <command>dd</command>)</title><screen># <userinput>tar cvf - * | rsh mercury dd of=/dev/rmt/0 obs=126b</userinput>
a answers/ 0 tape blocks
a answers/test129 1 tape blocks
a sc.directives/ 0 tape blocks
a sc.directives/sc.190089 1 tape blocks
a tests/ 0 tape blocks
a tests/test131 1 tape blocks
6+9 records in
0+1 records out</screen>
</example>
</task><task id="bkupsavefiles-74428"><title>How to Extract Files From a Remote Tape
Device</title><procedure><step id="bkupsavefiles-step-4"><para>Insert the tape into the tape drive.</para>
</step><step id="bkupsavefiles-step-82"><para>Change to a temporary directory.</para><screen>$ <userinput>cd /var/tmp</userinput></screen>
</step><step id="bkupsavefiles-step-83"><para>Extract the files from a remote tape device.</para><screen>$ <userinput>rsh</userinput> <replaceable>remote-host</replaceable> <userinput>dd if=/dev/rmt/</userinput><replaceable>n</replaceable> <userinput>| tar xvBpf -</userinput></screen><variablelist><varlistentry><term><command>rsh</command> <replaceable>remote-host</replaceable></term><listitem><para>Indicates a remote shell that is started to extract the files
from the tape device by using the <command>dd</command> command.</para>
</listitem>
</varlistentry><varlistentry><term><filename>dd if=/dev/rmt/</filename><replaceable>n</replaceable></term><listitem><para>Indicates the input device.</para>
</listitem>
</varlistentry><varlistentry><term><command>| tar xvBpf -</command></term><listitem><para>Pipes the output of the <command>dd</command> command to the <command>tar</command> command, which is used to restore the files.</para>
</listitem>
</varlistentry>
</variablelist>
</step><step id="bkupsavefiles-step-122"><para>Verify that the files have been extracted.</para><screen>$ <userinput>ls -l</userinput></screen>
</step>
</procedure><example id="fncsa"><title>Extracting Files From a Remote Tape Drive</title><screen>$ <userinput>cd /var/tmp</userinput>
$ <userinput>rsh mercury dd if=/dev/rmt/0 | tar xvBpf -</userinput>
x answers/, 0 bytes, 0 tape blocks
x answers/test129, 48 bytes, 1 tape blocks
20+0 records in
20+0 records out
x sc.directives/, 0 bytes, 0 tape blocks
x sc.directives/sc.190089, 77 bytes, 1 tape blocks
x tests/, 0 bytes, 0 tape blocks
x tests/test131, 84 bytes, 1 tape blocks
$ <userinput>ls -l</userinput></screen>
</example>
</task>
</sect1><sect1 id="bkupsavefiles-60201"><title>Copying Files and File Systems to Diskette</title><para>Before you can copy files or
file systems to diskette, you must format the diskette. For information on
how to format a diskette, see <olink targetptr="medformat-83002" remap="internal">Chapter&nbsp;2,
Managing Removable Media (Tasks)</olink>.</para><para>Use the <command>tar</command> command to copy UFS files to a single
formatted diskette. </para><para>Use the <command>cpio</command> command if you need to copy UFS files
to multiple formatted diskettes. The <command>cpio</command> command recognizes
end-of-media and prompts you to insert the next diskette.</para><sect2 id="bkupsavefiles-86"><title>What You Should Know When Copying Files
to Diskettes</title><itemizedlist><listitem><para>Copying files to a formatted diskette by using the <command>tar</command> <option>c</option> command destroys any files that are already on the diskette.</para>
</listitem><listitem><para>A diskette that contains a <command>tar</command> image is
not mountable.</para>
</listitem><listitem><para>If you need a multiple-volume interchange utility, use the <command>cpio</command> command. The <command>tar</command> command is only a single-volume
utility.</para>
</listitem>
</itemizedlist><para>For more information, see <olink targetdoc="refman1" targetptr="tar-1" remap="external"><citerefentry><refentrytitle>tar</refentrytitle><manvolnum>1</manvolnum></citerefentry></olink>.</para>
</sect2><task id="bkupsavefiles-84545"><title>How to Copy Files to a Single Formatted
Diskette (<command>tar</command>)</title><procedure><step id="bkupsavefiles-step-88"><para>Change to the directory that contains
the files you want to copy.</para>
</step><step id="bkupsavefiles-step-89"><para>Insert a formatted diskette that is
not write-protected into the drive.</para>
</step><step id="bkupsavefiles-step-90"><para>Make the diskette available.</para><screen>$ <userinput>volcheck</userinput></screen>
</step><step id="bkupsavefiles-step-91"><para>Reformat the diskette, if necessary.</para><screen>$ <userinput>rmformat -U /dev/rdiskette</userinput>
Formatting will erase all the data on disk.
Do you want to continue? (y/n)<userinput>y</userinput></screen>
</step><step id="bkupsavefiles-step-92"><para>Copy the files to diskette.</para><screen>$ <userinput>tar cvf /vol/dev/aliases/floppy0</userinput> <replaceable>filenames</replaceable></screen><para>The file names that you specify are copied to the diskette, overwriting
any existing files on the diskette.</para>
</step><step id="bkupsavefiles-step-123"><para>Verify that the files were copied.</para><screen>$ <userinput>tar tvf /vol/dev/aliases/floppy0</userinput></screen><para>For more information on listing files, see <olink targetptr="bkupsavefiles-78890" remap="internal">How to List the Files on a Diskette (tar)</olink>.</para>
</step><step id="bkupsavefiles-step-93"><para>Remove the diskette from the drive.</para>
</step><step id="bkupsavefiles-step-94"><para>Write the names of the files on the
diskette label.</para>
</step>
</procedure><example id="fncrw"><title>Copying Files to a Single Formatted Diskette (<command>tar</command>)</title><para>The following example shows how to copy files named <literal>evaluation*</literal> to
a diskette.</para><screen>$ <userinput>cd /home/smith</userinput>
$ <userinput>volcheck</userinput>
$ <userinput>ls evaluation</userinput>*
evaluation.doc   evaluation.doc.backup
$ <userinput>tar cvf /vol/dev/aliases/floppy0 evaluation*</userinput>
a evaluation.doc 86 blocks
a evaluation.doc.backup 84 blocks
$ <userinput>tar tvf /vol/dev/aliases/floppy0</userinput></screen>
</example>
</task><task id="bkupsavefiles-78890"><title>How to List the Files on a Diskette
(<command>tar</command>)</title><procedure><step id="bkupsavefiles-step-98"><para>Insert a diskette into the drive.</para>
</step><step id="bkupsavefiles-step-99"><para>Make the diskette available.</para><screen>$ <userinput>volcheck</userinput></screen>
</step><step id="bkupsavefiles-step-100"><para>List the files on a diskette. </para><screen>$ <userinput>tar tvf /vol/dev/aliases/floppy0</userinput></screen>
</step>
</procedure><example id="fncsd"><title>Listing the Files on a Diskette (<command>tar</command>)</title><para>The following example shows how to list the files on a diskette.</para><screen>$ <userinput>volcheck</userinput>
$ <userinput>tar tvf /vol/dev/aliases/floppy0</userinput>
rw-rw-rw-6693/10  44032 Jun  9 15:45 evaluation.doc
rw-rw-rw-6693/10  43008 Jun  9 15:55 evaluation.doc.backup
$</screen>
</example>
</task><task id="bkupsavefiles-53640"><title>How to Retrieve Files From a Diskette
(<command>tar</command>)</title><procedure><step id="bkupsavefiles-step-103"><para>Change to the directory where you
want to put the files.</para>
</step><step id="bkupsavefiles-step-104"><para>Insert the diskette into the drive.</para>
</step><step id="bkupsavefiles-step-105"><para>Make the diskette available.</para><screen>$ <userinput>volcheck</userinput></screen>
</step><step id="bkupsavefiles-step-106"><para>Retrieve files from the diskette. </para><screen>$ <userinput>tar xvf /vol/dev/aliases/floppy0</userinput></screen><para>All files on the diskette are copied to the current directory.</para>
</step><step id="bkupsavefiles-step-124"><para>Verify that the files have been retrieved. </para><screen>$ <userinput>ls -l</userinput></screen>
</step><step id="bkupsavefiles-step-107"><para>Remove the diskette from the drive.</para>
</step>
</procedure><example id="fncsn"><title>Retrieving Files From a Diskette (<command>tar</command>)</title><para>The following example shows how to retrieve all the files from a diskette.</para><screen>$ <userinput>cd /home/smith/Evaluations</userinput>
$ <userinput>volcheck</userinput>
$ <userinput>tar xvf /vol/dev/aliases/floppy0</userinput>
x evaluation.doc, 44032 bytes, 86 tape blocks
x evaluation.doc.backup, 43008 bytes, 84 tape blocks
$ <userinput>ls -l</userinput></screen><para>The following example shows how to retrieve an individual file from
a diskette. The file is extracted from the diskette and placed in the current
working directory.</para><screen>$ <userinput>volcheck</userinput>
$ <userinput>tar xvf /vol/dev/aliases/floppy0 evaluation.doc</userinput>
x evaluation.doc, 44032 bytes, 86 tape blocks
$ <userinput>ls -l</userinput></screen>
</example>
</task><sect2 id="bkupsavefiles-25999"><title>Archiving Files to Multiple Diskettes</title><para>If you are copying large files onto diskettes, you want to be prompted
to replace a full diskette with another formatted diskette. The <command>cpio</command> command
provides this capability. The <command>cpio</command> commands you use are
the same that you would use to copy files to tape, except you would specify <filename>/vol/dev/aliases/floppy0</filename> as the device instead of the tape device
name.</para><para>For information on how to use the <command>cpio</command> command, see <olink targetptr="bkupsavefiles-85934" remap="internal">How to Copy All Files in a Directory to a
Tape (cpio)</olink>.</para>
</sect2>
</sect1>
</chapter>