This chapter contains the following procedures for backing up and restoring the operating system, applications, and data:
Several methods exist for compressing a file system:
Files are compressed for the following reasons:
To compress the foo file and write the percentage compression to standard error, type:
compress -v foo
See the compress command for details about the return values but, in general, the problems encountered when compressing files can be summarized as follows:
Two procedures can be used to back up files and file systems: the SMIT fast paths smit backfile or smit backfilesys, and the backup command.
For additional information about backing up user files or file systems, see Backing Up User Files or File Systems in the AIX 5L Version 5.2 System Management Concepts: Operating System and Devices.
The following procedures describe how to make an installable image of your system.
Before backing up the rootvg volume group:
lslpp -l bos.sysmgt.sysbr
If your system has the sysbr fileset installed, continue the backup procedures.
If the lslpp command does not list the sysbr fileset, install it before continuing with the backup procedure. See Installing Optional Software and Service Updates in the AIX 5L Version 5.2 Installation Guide and Reference for instructions.
installp -agqXd device bos.sysmgt.sysbr
where device is the location of the software; for example,/dev/rmt0 for a tape drive.
Before backing up a user-defined volume group:
Task | SMIT Fast Path | Command or File |
---|---|---|
Backing up the rootvg volume group |
|
|
Verify a Backup Tape3 | smit lsmksysb | |
Backing up a user-defined volume group4 | smit savevg |
|
Notes:
- The mksysb command does not back up file systems mounted across an NFS network.
- The mksysb command requires this working space for the duration of the backup. Use the df command, which reports in units of 512-byte blocks, to determine the free space in the /tmp directory. Use the chfs command to change the size of the file system, if necessary.
- This procedure lists the contents of a mksysb backup tape. The contents list verifies most of the information on the tape but does not verify that the tape can be booted for installations. The only way to verify that the boot image on a mksysb tape functions correctly is by booting from the tape.
- If you want to exclude files in a user-defined volume group from the backup image, create a file named /etc/exclude.volume_group_name, where volume_group_name is the name of the volume group that you want to back up. Then edit /etc/exclude.volume_group_name and enter the patterns of file names that you do not want included in your backup image. The patterns in this file are input to the pattern matching conventions of the grep command to determine which files are excluded from the backup.
- If you choose to modify the VGName.data file to alter the size of a file system, you must not specify the -i flag or the -m flag with the savevg command, because the VGName.data file is overwritten.
For more information about installing (or restoring) a backup image, see "Installing BOS from a System Backup" in the AIX 5L Version 5.2 Installation Guide and Reference.
This procedure describes how to develop and use a script to perform a weekly full backup and daily incremental backups of user files. The script included in this procedure is intended only as a model and needs to be carefully tailored to the needs of the specific site.
This procedure describes how to write a crontab script that you can pass to the cron command for execution. The script backs up two user file systems, /home/plan and /home/run, on Monday through Saturday nights. Both file systems are backed up on one tape, and each morning a new tape is inserted for the next night. The Monday night backups are full archives (level 0). The backups on Tuesday through Saturday are incremental backups.
crontab -e
min hr day/mo mo/yr day/wk shell command 0 2 * * 1 backup -0 -uf /dev/rmt0.1 /home/plan
The command line shown assumes that personnel at the site are available to respond to prompts when appropriate. The -0 (zero) flag for the backup command stands for level zero, or full backup. The -u flag updates the backup record in the /etc/dumpdates file and the f flag specifies the device name, a raw magnetic tape device 0.1 as in the example above. See rmt Special File in the AIX 5L Version 5.2 Files Reference for information on the meaning of extension .1 and other extensions (1-7).
0 2 * * 1 backup -0 -uf/dev/rmt0.1 /home/plan 0 3 * * 1 backup -0 -uf/dev/rmt0.1 /home/run 0 2 * * 2 backup -1 -uf/dev/rmt0.1 /home/plan 0 3 * * 2 backup -1 -uf/dev/rmt0.1 /home/run 0 2 * * 3 backup -2 -uf/dev/rmt0.1 /home/plan 0 3 * * 3 backup -2 -uf/dev/rmt0.1 /home/run 0 2 * * 4 backup -3 -uf/dev/rmt0.1 /home/plan 0 3 * * 4 backup -3 -uf/dev/rmt0.1 /home/run 0 2 * * 5 backup -4 -uf/dev/rmt0.1 /home/plan 0 3 * * 5 backup -4 -uf/dev/rmt0.1 /home/run 0 2 * * 6 backup -5 -uf/dev/rmt0.1 /home/plan 0 3 * * 6 backup -5 -uf/dev/rmt0.1 /home/run
Running AIX systems cannot mount a remote tape device as if it were local to the system; however, data can be sent to a remote machine tape device using the rsh command. This section describes how to archive files to a remote tape device. The following procedure writes to a single tape only. Multiple-tape archives require specialized application software.
In the following procedure, assume the following:
The following instructions assume that both the local and remote user is root.
host SourceIPaddress
For the purposes of this example, assume you add the following
line to the .rhosts file:
sourcehost.mynet.com root
chmod 600 .rhosts
rsh remotehostIf everything is set up correctly, you should be granted shell access to the remote machine. You should not see a login prompt asking for a user name. Type exit to log out of this test shell.
9-track or 0.25-in. media blocksize: | 512 |
8-mm or 4-mm media blocksize: | 1024 |
tctl -f /dev/rmt0 statusIf you want to change the tape blocksize, use the chdev command. For example:
chdev -l rmt0 -a block_size=1024
find pathname -print | backup -ivqf- | rsh remotehost \ "dd of=/dev/rmt0 bs=blocksize conv=sync"
umount /myfs backup -0 -uf- /myfs | rsh remotehost \ "dd of=/dev/rmt0 bs=blocksize conv=sync"
find pathname -print | cpio -ovcB | rsh remotehost \ "dd ibs=5120 obs=blocksize of=/dev/rmt0"
tar -cvdf- pathname | rsh remotehost \ "dd of=/dev/rmt0 bs=blocksize conv=sync"
rdump -u -0 -f remotehost:/dev/rmt0 /myfs
The -u flag tells the system
to update the current backup level records in the /etc/dumpdates file. The -0 is
the setting of the Level flag. Backup level 0 specifies
that all the files in the /myfs directory are to be backed up.
For more information, see the rdump command description in AIX 5L Version 5.2 Commands Reference.
rsh remotehost "dd if=/dev/rmt0 bs=blocksize" | restore \ -xvqdf- pathname
rsh remotehost "dd if=/dev/rmt0 bs=blocksize" | restore \ -xvqf- pathname
rsh remotehost "dd if=/dev/rmt0 ibs=blocksize obs=5120" | \ cpio -icvdumB
rsh remotehost "dd if=/dev/rmt0 bs=blocksize" | tar -xvpf- pathname
cd /myfs
rrestore -rvf remotehost:/dev/rmt0
If you need to restore a backup image destroyed by accident, your most difficult problem is determining which of the backup tapes contains this file. The restore -T command can be used to list the contents of an archive. It is a good idea to restore the file in the /tmp directory so that you do not accidentally overwrite the user's other files.
If the backup strategy included incremental backups, then it is helpful to find out from the user when the file was most recently modified. This helps to determine which incremental backup contains the file. If this information cannot be obtained or is found to be incorrect, then start searching the incremental backups in reverse order (7, 6, 5, ...). For incremental file system backups, the -i flag (interactive mode) of the restore command is very useful in both locating and restoring the lost file. (Interactive mode is also useful for restoring an individual user's account from a backup of the /home file system.)
The procedures in the following table describe how to implement a level 0 (full) restoration of a directory or file system.
Make sure the device is connected and available. To check availability, type:
Restoring from Backup Image Tasks | ||
---|---|---|
Task | SMIT Fast Path | Command or File |
Restore Individual User Files | smit restfile | See restore command. |
Restoring a User File System | smit restfilesys |
|
Restoring a User Volume Group | smit restvg | See restvg -q command. |