Archiving Files and Remote Transfer

Introduction

To safeguard your files and directories, you can create a copy, or archive of the files and directories on a removable medium, such as a cartridge tape. You can use the archived copies to retrieve lost, deleted, or damaged files.

Archiving Techniques

You can use several commands to store, locate, and retrieve files on a tape device or from an archive file. Two of the commands you can use are:

  • The tar command, to create and extract files from a file archive or any removable media such as a tape or diskette
  • The jar command, to combine multiple files into a single archive file, and then compress the file

The tar Command

The tar command archives files to and extracts files from a single file called a tar file. The default device for a tar file is a magnetic tape device.

The syntax for the tar command is:

tar functions archivefile filenames
Note: You should use relative path names to archive files.

The table shows the functions associated with the tar command.

Functions for the tar Command
Function Definition
c
Creates a new tar file.
t
Lists the table of contents of the tar file.
x
Extracts files from the tar file.
f
Specifies the archive file or tape device. The default tape device is /dev/rmt/0. If the name of the archive file is “-“, the tar command reads from the standard input when reading from a tar archive or writes to the standard output if creating a tar archive.
v
Executes in verbose mode, writes to the standard output.
h
Follows symbolic links as standard files or directories.

Creating an Archive

You can use the tar command to create an archive file that contains multiple files or directories. You can then place the file on a tape or a diskette so that other users can share the file or attach it to email messages.

Creating an Archive on a Tape

To create an archive on a tape, first verify that the system has a tape drive available. You can use the mt utility with the status option to print status information about the tape unit. You use the mt utility to send commands to a magnetic tape drive.

Note: For more information on the use of the mt command to control a magnetic tape drive, refer to the mt man page.

The following example shows you how to use the default tape device to archive your home directory. In this example, user1 creates a tape archive of the user1 home directory.

$ cd
$ mt -f /dev/rmt/0 status
<output will be your local tape device info>
$ tar cvf /dev/rmt/0 .
a ./ 0 tape blocks
a ./.rhosts 1 tape blocks
a ./dante 3 tape blocks
a ./fruit 1 tape blocks
a ./dante_1 1 tape blocks
a ./dir1/ 0 tape blocks
a ./dir1/coffees/ 0 tape blocks
a ./dir1/coffees/beans/ 0 tape blocks
a ./dir1/coffees/beans/beans 24 tape blocks
... (output truncated)

You can also use the tar command to create an archive file containing multiple files or directories.

The following example shows you how to archive the file1, file2, and file3 files in an archive file called files.tar.

$ cd
$ tar cvf files.tar file1 file2 file3
a file1 2K
a file2 1K
a file3 1K

Creating an Archive on a Diskette

Before you can create a file archive on a diskette, insert a diskette into the appropriate drive on the system, and run the volcheck command. This command informs the Volume Management program to check for media in a drive.

Note: The Volume Management program provides automatic detection of removable media. However, because of hardware limitations in many floppy drives, the Volume Management program does not detect the presence of a newly-inserted diskette.

The volcheck command checks for all removable media managed by the Volume Management program. The volcheck command checks for all diskettes as a default. It instructs the Volume Management program to check each device path name in sequence and determine if a new diskette is in the diskette drive.

The syntax for the volcheck command is:

volcheck -v device_pathname

If you use the volcheck -v command without a device path name, one of the following messages appears:

media was found

or

no media was found
Note: The device path name for a diskette is /dev/diskette. You can use the device path name to instruct the Volume Management program to check each device path name in sequence and determine if new media has been inserted in the drive.

Performing the volcheck command creates the /floppy directory and its content when a diskette is present. You can use the cd command to access files on the diskette in the /floppy/floppy0 directory. You can also use the cp command to copy an archive into the /floppy/floppy0 directory on the diskette.

The following example shows you how to use the cp command to copy an archive file from your home directory to a diskette.

$ volcheck -v /dev/diskette
$ cd /floppy/floppy0
$ ls
$
$ cd
$ cp files.tar /floppy/floppy0
$ ls /floppy/floppy0
files.tar
Note: You can also access the files on a diskette from the File Manager window by selecting Open Floppy from the File Menu.

To eject a diskette from the diskette drive do one of the following:

  • Use the File Manager window.

    • Click File in the File Manager diskette window, and select the Eject option in the File menu.
    • Close the popup Watch Errors window.
  • Perform the cd command to change from the /floppy/floppy0 directory to your home directory.
$ cd

Perform the eject floppy command.

$ eject floppy

After a few seconds, the diskette ejects from the diskette drive, or a message appears to instruct you to manually eject the diskette.

You cannot eject removable devices while you are in the current working directory for the device. If you see an error message, such as Device busy, when trying to eject the diskette, you might still be in the working directory on the diskette. Perform the pwd command to see if you are in the /floppy/floppy0 directory. If you are in the /floppy/floppy0 directory, enter the cd command to return to your home directory. Then perform the eject command.

Viewing an Archive

You can view the names of all the files that have been written directly to a tape archive or a file archive.

Viewing an Archive From a Tape

To view the contents of the user1 home directory on a tape, perform the command:

$ tar tf /dev/rmt/0
/.rhosts
./dante
./fruit
./dante_1
./dir1/
./dir1/coffees/
./dir1/coffees/beans/
./dir1/coffees/beans/beans
./dir1/coffees/nuts
./dir1/coffees/brands
./dir1/fruit/
./dir1/trees/
<directory list truncated>

Viewing Files in an Archive File

To view the contents of the files.tar archive file, perform the command:

$ tar tf files.tar
file1
file2
file3

Retrieving tar Archive Data

You can retrieve or extract the contents of an archive that was written directly to a tape device or to a file.

Retrieving a Directory From a Tape

If the contents of your home directory are deleted, you can extract the directory contents from an archive tape.

To retrieve all the files from the tape archive, perform the commands:

$ cd
$ tar xvf /dev/rmt/0
x ., 0 bytes, 0 tape blocks
x ./.rhosts, 2 bytes, 1 tape blocks
x ./dante, 1319 bytes, 3 tape blocks
x ./fruit, 57 bytes, 1 tape blocks
x ./dante_1, 368 bytes, 1 tape blocks
x ./dir1, 0 bytes, 0 tape blocks
x ./dir1/coffees, 0 bytes, 0 tape blocks
x ./dir1/coffees/beans, 0 bytes, 0 tape blocks
x ./dir1/coffees/beans/beans, 12288 bytes, 24 tape blocks
x ./dir1/coffees/nuts, 0 bytes, 0 tape blocks
x ./dir1/coffees/brands, 0 bytes, 0 tape blocks
x ./dir1/fruit, 0 bytes, 0 tape blocks
x ./dir1/trees, 0 bytes, 0 tape blocks
... (output truncated)

You can extract files from an archive file using the tar command. The following example shows you how to extract files from the files.tar archive file for placement into the current directory.

$ tar xvf files.tar
tar: blocksize = 11
x file1, 1610 bytes, 4 tape blocks
x file2, 105 bytes, 1 tape blocks
x file3, 218 bytes, 1 tape blocks

Retrieving Files From a Diskette

To retrieve files archived to a diskette, you can follow the same process as you did for archiving to a diskette except that you copy files from the diskette back to your home directory.

The following example shows you how to retrieve the archived file files.tar from a diskette.

$ volcheck
$ cd /floppy/floppy0
$ ls
files.tar
$ cp files.tar /export/home/user1
$ cd
$ ls files.tar
files.tar
$ tar xvf files.tar

Leave a Comment

Your email address will not be published. Required fields are marked *

CAPTCHA * Time limit is exhausted. Please reload the CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top