You are on page 1of 7

Relative vs.

Absolute Paths

When restoring files backed up with the backup, cpio, or tar commands, find out FIRST whether
RELATIVE or ABSOLUTE pathnames were used BEFORE the restore is initiated. We recommend
using RELATIVE.

• Relative pathnames will have a ./ pre-fixed to their path. These files will be restored relative to
the current directory.
• Absolute pathnames won't have the ., just the /. These are restored with the full pathname to the
exact directory as specified on the archive device.

backup

Command typically used to backup files on an AIX platform. Distribution tapes for AIX are in this format. This
command will span across multiple tapes.

Backup by INODE is not recommended because it eliminates the capability to selectively restore files by
filename.

If you have more data to backup than can fit on one tape, you will probably want to perform INCREMENTAL
backups for files that have been modified within the last 24 hours for each day of the work week, followed by
making a complete backup of the system on the weekend.

The error message Volume on /dev/rfd0 is not in backup format is generated when an attempt is made to
extract a file NOT created by the backup command:

If your backup was successful, the last item logged by 'backup' is the time the backup finished and the
number of 512 byte block that were archived.

Example message of a successful backup:

Backup finished on Sat Aug 1 15:22:34 CDT 1992; there are 8700 blocks on 1 volumes.
Options What it does
-i Read standard input
-v List names of files being backed up
-f Name of output device (typically de/v/rmt0 for tape drive)
-e Won't attempt to compress or pack files that are greater than 24 MB.
-q Won't prompt user to insert tape
-p Pack data. Backup images by default are NOT packed. If you wish to pack your data, use this
option. The restore command has enough intelligence to determine if a backup image is packed or
not and take appropriate action

Examples What it does


find /u -print | backup Backup the file system /u to tape device using ABSOLUTE pathnames.
-ivf/dev/rmt0
find . -print | backup Backup files and directories under current directory (.) using RELATIVE
-iepqvf/dev/rmt0 | tee pathnames. The tee (|) will take as input the output of the backup command
/tmp/BACKUP.LOG (filenames being copied) and write them to the log file 'BACKUP.LOG' for
later review.
find /faxdata -mtime -1 -type f Find any REGULAR files (-type f) that have been modified within the past
-print | backup -ivf/dev/rmt0.1 24 hours (-mtime -1) and write them to the tape device but don't rewind
(/dev/rmt*.1) the tape after backup has finished.
backup -ivqf/dev/fd0 Backup files interactively. Select the file(s) to backup by typing in the file's
name. When done, press ^D to finish.
find / -print|backup If there is more than one tape drive attached to the system, then you can
-icvqf/dev/rmt0-1 specify a range of devices to the -f flag of the backup command. (/dev/rmt0-
1)

top of page

compress, uncompress, pack, unpack, zcat

Utilities to compress or expand data. The compress command reduces the size of the named file(s) and
renames it with a .Z extension. Compressed files can be restored to their original form using the
uncompress command. This utility appears to have a more EFFICENT packing scheme than the
PACK/UNPACK commands.

Examples What it does


compress -v /tmp/junk File /tmp/junk is compressed and gets renamed to /tmp/junk.Z. -v displays
the percentage of file shrinkage
uncompress /tmp/junk.Z Restores file to original file type and file size and changes the name to
/tmp/junk.
1)find . -print | backup The 3 commands will backup the current directory and compress that
-ivqpf /tmp/roger.bck backup image to a floppy diskette.
2) compress /tmp/roger.bck
3) find /tmp/roger.bck.Z -print
| backup -ivqf/dev/fd0
1) restore -xvf/dev/fd0 Restore the files archived from a floppy diskette. (In this example assume
2) uncompress < /tmp/roger.Z restored file=roger.Z) Uncompress the compressed image and restore this
| restore -xvf- file back to the file system
zcat /tmp/junk.Z > /tmp/junk1 Uncompresses /tmp/junk.Z into /tmp/junk1
find /u/COMPANY -print | Packs all the files under the specified directory (/u/COMPANY)
xargs pack -f
find /u/COMPANY -print | Unpacks all the files under the specified directory (u/COMPANY)
xargs unpack

top of page

cpio

Copies files to/from an archive storage device. This command is often used to copy files from UNIX to AIX
systems. This command will span across multiple tapes. cpio stands for CoPy Input to Output.

Options What it does


-c Writes header information in ascii format for portability across UNIX systems. The message Out of
phase--get help is generated when an attempt is made to extract a file not in cpio format OR if the
archive tape was written with the -c option. The cpio command doesn't have this option specified
when attemping to extract files from the media (eg., cpio -icdumpv < /dev/rmt0)
-r When restoring will prompt for new path/file to restore to
-v List the file name as it's being copied
-i Read from standard input, i.e. keyboard
-u Copies unconditionally. Older file replaces a newer one. Files with older modification times will
replace files with newer modification times.
-d Creates directories, if applicable
-t For table of contents

-C1 Performs block I/O in 512 byte blocks, if the block size of the device that wrote the data on the tape
was set to 512 bytes. Make sure you read with the same block size. If the block size that the data
was written to and about to be read from are two different sizes, this message will be displayed:
Cannot read from the specified device

Examples What it does


1) cd /u/roger Reads file names using the find command and copies to the floppy drive
2) find . -print | cpio -ocv (/dev/fd0).
> /dev/fd0
find . -cpio /dev/fd0 Saves files in current directory and writes this info to floppy. Same command as
-print above except much faster.
1) cd /u/roger Restore files and directories saved on the floppy device. These files are restored
2) cpio -icuvd < /dev/fd0 under the current directory (/u/roger) Only if relative pathnames (./<filename>)
were used.
cpio -itvcC1 < /dev/rmt0 List the table of contents from a tape device.
1) cd /u/roger Copies all files FROM one directory TO another WITHOUT changing the
2) find . -print | cpio permissions, owner/group or modification date of the file. Use the following
-dumpv /u/jerry command to verify that all files were copied:
find /u/roger -print | If the number of files encountered is the same for both directories its safe to
wcfind /u/jerry -print | wc assume that the directories are identical. NOTE: that the number of blocks
allocated to the SOURCE directory (/u/roger) may be larger than the
DESTINATION directory (/u/jerry), since compaction of the directory structure will
have occurred at the destination end.
cpio -imv Selectively restore the /home/roger/.profile file from floppy
/home/roger/.profile <
/dev/fd0
cpio -i "*.f" "*.c" Selectively restore only the *.f and *.c files from floppy
</dev/fd0

top of page

dd

Converts/copies files to/from an output device. DD stands for Data Dump. This command will NOT span
across multiple tapes. Common utility found on most versions of UNIX.

Examples What it does


dd if=/dev/rmt0 bs=512k | Reads the files off the tape device faster because of the blocking factor
cpio -icdmv (bs=blocksize of 512K or cache upto 1/2 MB at a time)
dd if=rs6000.data Copies the data from the input file (if=rs6000.dat) to the output tape device
of=/dev/rmt0.4 bs=1024 (/dev/rmt0). The rmt*.4 device extension means output is written in 1600 bpi
conv=ebcdic format. This creates an EBCDIC low density tape, resulting in a 1024 byte
blocked non-labeled file. To extract this file on the AS/400, create a physical
file with a record length of 1024 bytes. Use the CPYFRMTAP command to
copy the file. NOTE: When copying data from an EBCDIC machine, make sure
your BLOCK SIZE is set to 0 on the tape device
dd if=unixfile.txt Copies the data from the input file (if=unixfile.txt) to output name
of=DOSFILE.TXT (of=DOSFILE.TXT) and converts the source data to UPPERCASE characters.
conv=ucase
tar -cvf- /u/roger | dd Copies the ABSOLUTE path /u/roger using the tar utility. To speed this
of=/dev/rmt0 bs=1024k process up, these files are piped to the dd utility using a cache buffer size of 1
MB.
dd if=/dev/rhdisk0 Copies the raw physical volume named hdisk0 to the raw physical volume
of=/dev/rhdisk1 bs=5120b named hdisk1. This represents a copy disk utility.
dd if=/dev/rmt0 Copies the data from the tape device (if=/dev/rmt0) and creates an output file
of=/tmp/ascii_file (/tmp/ascii_file) - which is BYTE swapped (conv=swab) as it is being written
conv=swab out. This needs to be done if your copying ascii files from a System V Unix
machine (unisys to the RS/6000)
dd if=/dev/rmt0.1 Useful when reading an ASCII file that is NOT delimited by a NL character.
of=/tmp/data1 cbs=242
ibs=3240
conv=sync,unblock

dd if=/dev/rmt0.1 Will read a record size of 147 bytes, a block size of 2940 bytes, and convert
of=/tmp/data1 cbs=147 the output to an ASCII file.
ibs=2940 conv=ascii

top of page

mksysb

High-level shell command for backing up mounted file systems in the rootvg volume group. mkszfile -f
must be called prior to mksysb in order to create the /.fs.size file that mksysb uses to determine which files
will be backed up.

8MM TAPE DEVICE

An 8mm tape drive is the preferred method of backing up your system because that tape can be used to
recreate the rootvg image if one or more physical volumes fail. Each of the file systems MUST have at least
500 blocks free when the mksysb backup is made. The system will need some work space in each file
system when it is installing from a mksysb backup.

To utilize the full 2.3 gb tape capacity...

• Set the blocksize to 1024


• Edit the /usr/lpp/bosinst/diskette/startup2 file
o Change the following line from 512 to 1024. /etc/methods/chggen -a rmt0 -a
block_size=1024
• Create a new install/maint diskette

MKSYSB can create a BOOTABLE tape. Further, the data is archived in TAR format. In order to look at the
names of files backed up by this command, perform the following:

• tctl -f/dev/rmt1.1 fsf 3


• tar -tvf/devrmt1.1

Example: mkszfile -f && mksysb /dev/rmt0


-f forces extending the /usr or /tmp file system if not enough working space (8 MB) exists. This command
should ALWAYS succeed unless a tape has not been inserted into the archive device (eg., rmt0), or the tape
is either write-protected or has defective media.
top of page

restore

Retrieve information from archive device created with the backup command. Default device is /dev/fd0.
This command will read a backup image spread across multiple tapes.

Examples What it does


restore -T=table of contents, -v=list the file name being copied, -f=name of output device. Will
-Tvf/dev/rmt0 list the tape's table of contents. If you forget to label the tape with the date that the
tape was made, use this command to report back the date this archive was created.
restore -xvf/dev/rmt0 Restores all files that start with "My" from the /usr/tmp directory
./usr/tmp/My*
restore Restores the directory named /usr/tmp from tape device
-xdvf/dev/rmt0
./usr/tmp
restore -xvf/dev/rmt0 Restores all the files located on the tape device that were backed up using the backup
command.
restore -xvf/dev/rmt0 -x=extract data from output device. Restores only the file named ./tmp/TestFile from
./tmp/TestFile the tape device. If the subdirectory /tmp doesn't exist in the current directory, then that
subdirectory will be made prior to restoring 'TestFile'.
1) tctl -f/dev/rmt0 1. Rewind to the beginning of tape. 2. Review files on FIRST backup image. 3. Review
rewind files on SECOND backup image)
2) restore -s1 Displays the table of contents for multiple backup images. s1=specifies that multiple
-Tvf/dev/rmt0.1 backups are on the tape and that the restore command skips to the backup specified
3) restore -s1 by the number associated with the 's' option. The 0.1 for the output device (-f flag)
-Tvf/dev/rmt0.1 means that once the tape has been read, it will not rewind. If only the second backup
image was needed, could have just typed in: restore -s2 -Tvf/dev/rmt0.1
1) tctl -f/dev/rmt0.1 If by chance the ./unix file was deleted, go back to your install tape and extract the file
fsf 3 that needs to be restored. The first three images on the tape are BOSBOOT,
2) restore INSTALL/MAINT, followed by the TOC (table of contents) image.
-xvqf/dev/rmt0.1
./unix
restbyname Selectively restore ONLY those files listed in file /tmp/DISK.LIS
-xvqf/dev/fd0 -Z
/tmp/DISK.LIST

top of page

tapechk

Performs consistency checks on a tape device. Primarily used to check tapes written in backup format.

Example: tapechk 2 ( Checks the first 2 files found on the tape device.)

top of page

tar

Probably the easiest command to use when transferring files from one UNIX system to another. This
command will NOT span across multiple tapes. Tar stands for Tape ARchiver.
When using this command while performing a SELECTIVE restore from a tape device (eg;., tar -xvf/dev/rmt0
./etc/motd), the tar command will continue to run until the end of tape is encountered, even after the file has
been found. The error message tar: directory checksum error (0 != 12345) Tar is an older utility than
cpio or backup/restore is generated when an attempt is made to extract a file that is NOT in tar format.

Options What it does


-c Writes (creates) files (appends to archive device)
-x Extract (read) files from archive device
-v Verbose mode (displays names)
-f Device name to use

Examples What it does


tar -cvf- * | dd of=/dev/rmt0 Copies all the files and subdirectories from the current directory and pipes the
bs=128k output to the dd command for faster archiving.
dd if=/dev/rmt0 bs=128k | tar Use the dd command to read the tape device for faster archiving and pipe the
-xvf- output to the tar command to restore the archived files.
tar -tvf/dev/rmt0 List the table of contents of the tape device.
tar -cvf/dev/rmt0 /u/jones Copies the jones account to the archive device named /dev/rmt0.
tar -xvf/dev/rmt0 Selectively copies ONLY the newdata and olddata directories from the tape to
tmp/newdata /tmp/olddata the current directory.
tar -cvf- * | xargs compress Copies all the files from the current directory and compresses them into the
-v > /tmp/tar.Z file named tar.Z.

top of page

tcopy

Copies from one magnetic tape device to another. This command will work for copying multiple backup
images from one media type to another. It will continue to copy until two end-of-tape marks are encountered.

Examples What it does


tcopy Displays ALL the backup images and their size for the tape your currently viewing.
/dev/rmt0
tcopy Copies all the data from one media type to another until two end of tape marks are
/dev/rmt0 encountered. In the example above, rmt0 could be a 8mm device and rmt1 may be a 1/4"
/dev/rmt1 tape device. If the error message: tcopy: Cannot open /dev/rmt?' is displayed, make sure
the destination device is not write-protected.

top of page

tctl

Command used to fast forward a tape device (Tape ConTroL).

Examples What it does


tctl -f/dev/rmt0 Rewind the tape device.
rewind
tctl Move tape forward to the second tape mark. The .1 on the rmt0 device instructs the device
-f/dev/rmt0.1 fsf NOT to rewind after performing the command. Use this command to skip past unwanted
tape images - assumming there are multiple archive images on the tape to skip past.
tctl -f/dev/rmt0 Moves the tape to the beginning, end, and back to the beginning again. Used to retension
retension the tape when encountering multiple read errors on restore operations.

top of page

Backup files from a remote computer

The local host MUST be included in remote's hosts /etc/hosts.equiv file. The local host and user name
MUST be included in the $HOME/.rhosts file at the user account at the remote machine.

Examples What it does


rsh lanai -l roger "dd Restores files FROM a remote tape drive on a host named 'lanai'
if=/dev/rmt0" | tar -xvf-
tar -cvf- * | rsh lanai -l roger The tar command will write it's output to the rsh command which pipes the
"dd of=/dev/rmt0 bs=64k data to the remote host (lanai) and the tape drive (/dev/rmt0). Specify -l
conv=block" <UserName> if the local user is different from the remote user.
tar -cvf- * | rexec lanai " dd Uses the floppy drive device on node lanai to store files in tar format.
of=/dev/fd0 bs=4096"

You might also like