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

System Management Guide: Operating System and Devices

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.


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 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.1 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.

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