Wednesday, January 5, 2011

CPIO backup command in AIX

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

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 -ivqpf /tmp/roger.bck
2) compress /tmp/roger.bck
3) find /tmp/roger.bck.Z -print | backup -ivqf/dev/fd0 The 3 commands will backup the current directory and compress that backup image to a floppy diskette.


1) restore -xvf/dev/fd0
2) uncompress < /tmp/roger.Z | restore -xvf- Restore the files archived from a floppy diskette. (In this example assume restored file=roger.Z) Uncompress the compressed image and restore this file back to the file system zcat /tmp/junk.Z > /tmp/junk1 Uncompresses /tmp/junk.Z into /tmp/junk1

find /u/COMPANY -print | xargs pack -f Packs all the files under the specified directory (/u/COMPANY)
find /u/COMPANY -print | xargs unpack Unpacks all the files under the specified directory (u/COMPANY)

back up in AIX

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.

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 -ivf/dev/rmt0 Backup the file system /u to tape device using ABSOLUTE pathnames.

find . -print | backup -iepqvf/dev/rmt0 | tee /tmp/BACKUP.LOG

Backup files and directories under current directory (.) using RELATIVE pathnames. The tee (|) will take as input the output of the backup command (filenames being copied) and write them to the log file 'BACKUP.LOG' for later review.


find /faxdata -mtime -1 -type f -print | backup -ivf/dev/rmt0.1 Find any REGULAR files (-type f) that have been modified within the past 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 -icvqf/dev/rmt0-1 If there is more than one tape drive attached to the system, then you can specify a range of devices to the -f flag of the backup command. (/dev/rmt0-1)