23.3 Using fbackup and frecover

   

23.3 Using fbackup and frecover

The first thing to keep in mind about the fbackup and frecover commands is that they are specific to HP-UX. In case you want to transfer data to a nonHP-UX system, don't use fbackup . However, if you want to back up data for disaster recovery, use of these commands may be more flexible and convenient compared with tar . The fbackup command is used to create a backup and frecover is used to restore data. You can use 10 backup levels with fbackup ranging from 0 to 9. Zero is the topmost backup level and is used for a full backup. If the fbackup command is used without a backup level, level 0 is assumed as the default level, and a full backup is performed. Backup levels 19 are used for incremental backup. As in the three-level backup scheme mentioned earlier, use backup level 0 for a full backup, backup level 1 for a weekly backup, and backup level 2 for a daily backup. However, you can use any level between 2 and 9 for a daily backup.

Creating a Backup

The fbackup command requires some command line options to perform a backup. You should specify the media on which the backed -up data is going to be stored and the files to be included in the backup process. A typical fbackup command to backup the /etc directory and its output is as shown here.

 #  fbackup -v -f /dev/rmt/0m -i /etc  fbackup(1004): session begins on Wed Nov 24 10:25:17 1999 fbackup(3203): volume 1 has been used 1 time(s) fbackup(3024): writing volume 1 to the output file /dev/rmt/0m     1: / 2     2: /etc 12     3: /etc/#hosts 4040     4: /etc/.pwd.lock 0     5: /etc/.supported_bits 3     6: /etc/MANPATH 1     7: /etc/PATH 1     8: /etc/SHLIB_PATH 1     9: /etc/SnmpAgent.d 1    10: /etc/SnmpAgent.d/snmpd.conf 14    11: /etc/SnmpAgent.d/snmpinfo.dat 111    12: /etc/TIMEZONE 1 <Output truncated from here>   538: /etc/wall   539: /etc/whodo   540: /etc/wtmp   541: /etc/xtab 0   542: /etc/yp   543: /etc/ypbind   544: /etc/zoneinfo fbackup(1005): run time: 21 seconds fbackup(3055): total file blocks read for backup: 7674 fbackup(3056): total blocks written to output file /dev/rmt/0m:   10158 

This command backs up the /etc directory on tape drive /dev/rmt/0m . The output of the command is truncated from the middle to keep it short. At the start of execution, the fbackup command shows the start time of the backup. At the end of the backup process, the commands shows the total time used for the backup and the number of blocks written to the output media. The start and end times are used when you perform incremental backup to determine which files have already been backed up. The -i option is used to include files or directories in the backup. If you don't want to include a complete directory tree in the backup, you can use the -e option to exclude some of its subdirectories. For example, the following command includes every file under the /etc directory tree except the /etc/lp subdirectory.

 fbackup -v -f /dev/rmt/0m -i /etc e /etc/lp 

Using Graph Files

For a routine backup process where only selective directories are included in the backup process, you need not specify all included directories and subdirectories on the command line. Instead, you can create a graph file that contains a list of all included and excluded directories. The following is an example of a typical graph file.

 #  cat gfile  i /etc i /home i /var/spool/cron i /var/mail e /etc/lp # 

The lines starting with the character i show directories that are included in the backup. The lines starting with the character e show excluded directories. An fbackup command that uses this graph file is like the following.

 fbackup -v -g gfile -f /dev/rmt/0m 

The fbackup command checks every line in the graph file and backs up all the directories included in the backup, excluding the others. You can create multiple graph files for routine backup tasks .

Creating an Incremental Backup

When you use the fbackup command with the -u option, it updates the /var/adm/fbackupfiles/dates file that keeps a record of fbackup activity. Don't forget that the dates file will be created or appended ONLY if the subdirectory /var/adm/fbackupfiles already exists. This is a simple text file and the information included in the file is as follows .

  • date, start time, and end time of the backup

  • backup level

  • graph file used with the fbackup command

This information is used when creating a backup in the future. At the next backup, the fbackup command checks if the graph file was used with an earlier backup at a higher backup level (lower number) and the time of that backup. If the graph file is used with such a backup at an earlier time, only those files are backed up that have a time stamp newer than that time. To create a backup using the gfile at level 2, the following command is used. The first few lines are also shown where you can see additional information about the history of the previous backup. Since this is the first backup with the -u option, no history below level 2 is available.

 #  fbackup -v -g gfile -u -2 -f /dev/rmt/0m  fbackup(1421): no history is available for graph file gfile   (below level 2) fbackup(1004): session begins on Wed Nov 24 20:39:54 1999 fbackup(3203): volume 1 has been used 1 time(s) fbackup(3024): writing volume 1 to the output file /dev/rmt/0m     1: / 2     2: /etc 12 

Because no history of any backup above level 2 is available, this will be a full backup. Now information of this backup is stored in the /var/adm/fbackupfiles/dates file, which will be used at the next backup time. Let's perform a backup at level 3 with the same graph file.

 #  fbackup -v -g gfile -u -3 -f /dev/rmt/0m  fbackup(1418): the last level 2 session for graph gfile was         started  : Wed Nov 24 20:41:16 1999         finished : Wed Nov 24 20:41:36 1999 fbackup(1004): session begins on Wed Nov 24 20:42:41 1999 fbackup(1019): warning: none of the specified files needed to   be backed up fbackup(1005): run time: 1 seconds fbackup(3055): total file blocks read for backup: 0 fbackup(3056): total blocks written to output file : 0 

No file is backed up as expected because a backup was performed at level 2 and none of the included files were changed after the completion of that backup. As you can see, the command also lists the start and finish times of the last backup.

It should be noted that incremental backup can only be performed using a graph file by using the -g option along with the -u option. If you include or exclude directories on the command line, the -u option can't be used with fbackup .

Other common options used with the fbackup command are shown in Table 23-2.

Table 23-2. Options Used with the fbackup Command
Option Meaning
-f Device used for backup media
-0 to -9 Backup level
-u Update the /var/adm/fbackupfiles/dates file
-v Verbose mode; display the activity of the command
-i Include the path in the backup
-e Exclude the path from the backup
-g Graph file used with fbackup
-I Create an index file showing a list of files backed up

Recovering Backed-up Data

The frecover command is used to restore a backup. While restoring, it compares files that already exist on the system and restores only those files that are needed. A typical frecover command to restore data from a tape drive is as follows.

 frecover -x -v -f /dev/rmt/0m -g gfile 

If you use this command and no file needs to be restored, it shows nothing, as all the files already exist. However, if you remove one file or directory from your system, it will restore it. Let's remove /home/lost+found and then use the same command again.

 #  rm r /home/lost+found  #  frecover -x -v -f /dev/rmt/0m -g gfile  drwxr-xr-x      root    root    /home/lost+found # 

Now only the removed directory is restored. If you want to recover everything, use the -r option with the frecover command. The frecover defaults to the /dev/rmt/0m tape drive, and the above command can also be used as:

 frecover -x -v -g gfile 

Options used with the frecover command are listed in Table 23-3.

Table 23-3. Options Used with the frecover Command
Option Meaning
-r Recover everything
-g Use the graph file for the selection of recovered files
-v Verbose mode; display the command activity
-o Force the command to overwrite a new file with an older file
-x Restore the selected files specified by the graph file or selected with the -i and -e options
-i Include the files in the restore process
-e Exclude the files in the restore process
-f Use the device from which to restore data

   
Top


HP Certified
HP Certified: HP-UX System Administration
ISBN: 0130183741
EAN: 2147483647
Year: 2000
Pages: 390
Authors: Rafeeq Rehman

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net