System Administration Guide
Chapter 3, Backing up filesystems

Performing unattended backups

Performing unattended backups

Because running backups can slow down the system, you might find it more convenient to perform backups when the system load is low, for example, during early mornings. You can set up your system to run backups when the system is unattended.

NOTE: A single day's backups must fit on one volume for unattended backups to succeed.

To set up your system for incremental unattended backups, add an entry in the root crontab file to specify that cron(C) run the cbackup(ADM) shell script at the desired times. Only root can run cbackup (directly or from cron); users with backup subsystem authorizations cannot run cbackup.

Using cbackup bypasses the backup schedule for a particular filesystem, and calls the cpio(C) utility directly to perform the backup. However, cbackup still allows you to make incremental backups. cbackup takes these arguments and passes them to cpio:

 Argument     Description
 level        backup level to perform (0, 1, or 2)
 len          capacity of the backup media volume (in KB)
 device       device name on which to record the backup,
              for example, /dev/rct0 for a cartridge tape
 filesystem   device name of the filesystem to back up,
              for example, /dev/root 

NOTE: cbackup looks up the mount point of the filesystem in /etc/default/filesys; because cbackup uses cpio, the filesystem must be mounted when it is backed up.

For example, to run a complete (Level 0) backup of the root filesystem on a 150MB cartridge tape at 2:00am every morning, edit the /usr/spool/cron/crontabs/root file and add the following cbackup line:

   0 2 * * * /usr/lib/sysadmin/cbackup 0 150000 /dev/rct0 /dev/root
Even though cbackup bypasses the backup schedule, you can construct a hierarchy of incremental backups by stating in the crontab file when to perform a particular level.

For example, to perform a Level 1 backup of the root filesystem at 2:00am every weekday morning and a complete (Level 0) backup on a 150MB cartridge tape on Saturday morning, include the following cbackup lines in the crontab file:

   0 2 * * 1-5 /usr/lib/sysadmin/cbackup 1 150000 /dev/rct0 /dev/root
   0 2 * * 6   /usr/lib/sysadmin/cbackup 0 150000 /dev/rct0 /dev/root
When you run unattended backups, remember to change the backup media in the drive between backups and label and store the incremental backups. See ``Maintaining backup archives and records''.

To back up more than one filesystem on the same unattended media device (without inserting new media), run the backups sequentially. The best way to do this is to create a shell script in the /usr/lib/sysadmin directory (for example, bscript) to make the calls to cbackup. Then, add an entry to root's crontab file to run bscript. Remember, the combined total size of the filesystems you want to back up must fit on one volume for these unattended backups to succeed.

In this example, /usr/lib/sysadmin/bscript performs a Level 1 backup of the /u and /w filesystems to a 150MB cartridge tape (the size of /w is 100MB; /u is 50MB):

   /usr/lib/sysadmin/cbackup 1 150000 /dev/nrct0 /dev/w
   /usr/lib/sysadmin/cbackup 1 50000 /dev/nrct0 /dev/u
   tape rewind /dev/xct0
The len argument to the first cbackup command is 150000 because the total capacity of the media at that time is 150MB; len is 50000 for the second call to cbackup because the /w filesystem has already been backed up, reducing the total capacity of the device to 50MB.

NOTE: In this example, the device is /dev/nrct0, the no-rewind tape device. Use this device instead of /dev/rct0 so that the tape does not automatically rewind to the beginning after backing up /dev/w. The tape rewind command rewinds the tape to the beginning after the backup of /u is complete.

Now, add an entry to /usr/spool/cron/crontabs/root to run bscript every weekday morning at 2:00am:

   0 2 * * 1-5 /usr/lib/sysadmin/bscript

See also: