[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

System Management Guide:
Operating System and Devices

Backing Up and Restoring Information

This chapter contains the following procedures for backing up and restoring the operating system, applications, and data:

Compressing Files

Several methods exist for compressing a file system:

Files are compressed for the following reasons:

Procedure

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:

Backing Up User Files or File Systems

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.

Prerequisites

Backing Up User Files or File Systems Tasks
Task SMIT Fast Path Command or File
Back Up User Files smit backfile
  1. Log in to your user account.
  2. Backup: find . -print | backup -ivf /dev/rmt0
Back Up User File Systems smit backfilesys
  1. Unmount files systems that you plan to back up. For example: umount all or umount /home /filesys1
  2. Verify the file systems. For example: fsck /home /filesys1
  3. Back up by i-node. For example: backup -5 -uf/dev/rmt0 /home/libr
  4. Restore the files using the following command:Note restore -t
Note
If this command generates an error message, you must repeat the entire backup.

Backing Up the System Image and User-Defined Volume Groups

Backing Up Your System

The following procedures describe how to make an installable image of your system.

Prerequisites

Before backing up the rootvg volume group:

Before backing up a user-defined volume group:

Backing Up Your System Tasks
Task SMIT Fast Path Command or File
Backing up the rootvg volume group
  1. Log in as root.
  2. Mount file systems for backup.1smit mountfs
  3. Unmount any local directories that are mounted over another local directory. smit umountfs
  4. Make at least 8.8MB of free disk space available in the /tmp directory.2
  5. Back up: smit mksysb
  6. Write-protect the backup media.
  7. Record any backed-up root and user passwords.
  1. Log in as root.
  2. Mount file systems for backup.1 See mount command.
  3. Unmount any local directories that are mounted over another local directory. See umount command.
  4. Make at least 8.8MB of free disk space available in the /tmp directory.2
  5. Back up. See mksysb command.
  6. Write-protect the backup media.
  7. Record any backed-up root and user passwords.
Verify a Backup Tape3 smit lsmksysb  
Backing up a user-defined volume group4 smit savevg
  1. Modify the file system size before backing up, if necessary.5 mkvgdata VGName then edit /tmp/vgdata/VGName/VGName.data
  2. Save the volume group. See the savevg command.

Notes:
  1. The mksysb command does not back up file systems mounted across an NFS network.
  2. 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.
  3. 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.
  4. 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.
  5. 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.

Implementing Scheduled Backups

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.

Prerequisites

Back Up File Systems Using the cron Command

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.

  1. The first step in making the crontab script is to issue the crontab-e command. This opens an empty file where you can make the entries that are submitted to the cron script for execution each night (the default editor is vi). Type:
    crontab -e 
  2. The following example shows the six crontab fields. Field 1 is for the minute, field 2 is for the hour on a 24-hour clock, field 3 is for the day of the month, and field 4 is for the month of the year. Fields 3 and 4 contain an * (asterisk) to show that the script runs every month on the day specified in the day/wk field. Field 5 is for the day of the week, and can also be specified with a range of days, for example, 1-6. Field 6 is for the shell command being run.
    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).

  3. Type a line similar to that in step 2 for each file system backed up on a specific day. The following example shows a full script that performs six days of backups on two file systems:
    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
  4. Save the file you created and exit the editor. The operating system passes the crontab file to the cron script.

Create a Remote Archive

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:

blocksize
Represents the target tape device blocksize.
remotehost
Is the name of the target system (the system that has the tape drive).
sourcehost
Is the name of the source system (the system being archived).
/dev/rmt0
Is the name of the remote tape device
pathname
Represents the full pathname of a required directory or file.

The following instructions assume that both the local and remote user is root.

  1. Ensure you have access to the remote machine. The source machine must have access to the system with the tape drive. (The target system can be accessed using any of the defined users on that system, but the user name must have root authority to do many of the following steps.)
  2. Using your favorite editor, create a file in the / (root) directory of the target system called .rhosts that allows the source system access to the target system. You need to add the authorized host name and user ID to this file. To determine the name of the source machine for the .rhosts file, you can use the following command:
    host SourceIPaddress
    For the purposes of this example, assume you add the following line to the .rhosts file:
    sourcehost.mynet.com   root
  3. Save the file and then change its permissions using the following command:
    chmod 600 .rhosts
  4. Use the rsh command to test your access from the source machine. For example:
    rsh remotehost
    If 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.
  5. Decide on the appropriate tape device blocksize. The following are the recommended values:
    9-track or 0.25-in. media blocksize: 512
    8-mm or 4-mm media blocksize: 1024
    If you are unsure and want to check the current block size of the tape device, use the tctl command. For example:
    tctl -f /dev/rmt0 status
    If you want to change the tape blocksize, use the chdev command. For example:
    chdev -l rmt0 -a block_size=1024
  6. Create your archive using one of the following methods:
    Backup by Name
    To remotely create a backup archive by name, use the following command:
    find pathname -print | backup -ivqf- | rsh remotehost \
        "dd of=/dev/rmt0 bs=blocksize conv=sync"
    Backup by inode
    To remotely create a backup archive by inode, first unmount your file system then use the backup command. For example:
    umount /myfs
    backup -0 -uf- /myfs | rsh remotehost \
         "dd of=/dev/rmt0 bs=blocksize conv=sync"
    Create and Copy an Archive to Remote Tape
    To create and copy an archive to the remote tape device, use the following command:
    find pathname -print | cpio -ovcB | rsh remotehost \
        "dd ibs=5120 obs=blocksize of=/dev/rmt0"
    Create a tar Archive
    To remotely create a tar archive, use the following command:
    tar -cvdf- pathname | rsh remotehost \
        "dd of=/dev/rmt0 bs=blocksize conv=sync"
    Create a Remote Dump
    To remotely create a remote dump of the /myfs file system, use the following command:
    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.
  7. Restore your remote archive using one of the following methods:
    Restore a Backup by Name
    To restore a remote backup archive by name, use the following command:
    rsh remotehost "dd if=/dev/rmt0 bs=blocksize" | restore \
         -xvqdf- pathname
    Restore a Backup by inode
    To restore a remote backup archive by inode, use the following command:
    rsh remotehost "dd if=/dev/rmt0 bs=blocksize" | restore \
        -xvqf- pathname
    Restore a Remote cpio Archive
    To restore a remote archive created with the cpio command, use the following command:
    rsh remotehost "dd if=/dev/rmt0 ibs=blocksize obs=5120" | \
         cpio -icvdumB 
    Restore a tar Archive
    To restore a remote tar archive, use the following command:
    rsh remotehost "dd if=/dev/rmt0 bs=blocksize" | tar -xvpf- pathname
    Restore a Remote Dump
    To restore a remote dump of the /myfs file system, use the following command:
    cd /myfs
    rrestore -rvf remotehost:/dev/rmt0

Restoring from Backup Image Individual User Files

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.

Prerequisites

Make sure the device is connected and available. To check availability, type:


lsdev -C | pg
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
  1. mkfs /dev/hd1
  2. mount /dev/hd1 /filesys
  3. cd /filesys
  4. restore -r
Restoring a User Volume Group smit restvg See restvg -q command.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]