backup File

Purpose

Copies the file system onto temporary storage media.

Description

A backup of the file system provides protection against substantial data loss due to accidents or error. The backup command writes file system backups in the backup file format, and conversely, the restore command reads file system backups. The backup file contains several different types of header records along with the data in each file that is backed up.

Header Records

The different types of header records for by-name backups are:

Header Record Description
FS_VOLUME Exists on every volume and holds the volume label.
FS_NAME_X Holds a description of a file backed up by name.
FS_END Indicates the end of the backup. This header appears at the end of the last volume.

The different types of header records for by-inode and name backups are:

Header Record Description
TS_TAPE Exists on every volume and holds the volume label.
TS_BITS Describes the directory structure.
TS_CLRI Describes the unused i-node numbers on the backup system.
TS_INODE Describes the file.
TS_ADDR Indicates a continuation of the preceding file.
TS_END Indicates the end of the backup.

The descriptions of the fields of the header structure for by-inode backups are:

Header Record Description
c_type The header type.
c_date The current dump date.
c_ddate The file system dump date.
c_volume The volume number.
c_tapea The number of the current header record.
c_inumber The i-node number on this record.
c_magic The magic number.
c_checksum The value that would make the record sum to the CHECKSUM value.
bsd_c_dinode A copy of the BSD i-node as it appears on the BSD file system.
c_count The number of characters in the c_addr field.
c_addr A character array that describes the blocks being dumped for the file.
xix_flag Set to the XIX_MAGIC value if doing the backup of a file system.
xix_dinode The real di-node from the file system.

Each volume except the last ends with a tape mark (read as an end of file). The last volume ends with a TS_END record and then the tape mark.

By-Name Format

The format of a by-name backup is:

FS_VOLUME

FS_NAME_X (before each file)

File Data

FS_END

By-Inode Format

The format of a by-inode backup follows:

TS_VOLUME

TS_BITS

TS_CLRI

TS_INODE

TS_END

A detailed description of the by-inode header file follows:

union u_spcl {
    char dummy[TP_BSIZE];
    struct s_spcl {
        int       c_type;                         /* 4 */
        time_t    c_date;                         /* 8 * /
        time_t    c_ddate;                        /* 12 */
        int       c_volume;                       /* 16 */
        daddr_t   c_tapea;                        /* 20 */
        ino_t     c_inumber;                      /* 24 */
        int       c_magic;                        /* 28 */
        int       c_checksum;                     /* 32 */
        struct    bsd_dinode   bsd_c_dinode;      /* 160 */
        int       c_count;                        /* 164 */
        char      c_addr[TP_NINDIR];              /* 676 */
        int       xix_flag;                       /* 680 */
        struct    dinode       xix_dinode;        /* 800 */
    } s_spcl;
} u_spcl;

Constants

Constants used to distinguish these different types of headers and define other variables are:

#define OSF_MAGIC    (int)60011
#define NFS_MAGIC    (int)60012    /* New File System Magic    */
#define XIX_MAGIC    (int)60013    /* Magic number for v3   */
#define BYNAME_MAGIC (int)60011    /* 2.x magic number         */
#define PACKED_MAGIC (int)60012    /* 2.x magic number for     */
                                   /* Huffman packed format    */
#define CHECKSUM     (int)84446    /* checksum magic number    */
#define TP_BSIZE     1024          /* tape block size          */
#define TP_NINDIR    (TP_BSIZE/2)  /* num of indirect pointers */
                                   /* in an inode record       */
#define FS_VOLUME    0             /* denotes a volume header  */
#define FS_END       7             /* denotes an end of backup */
#define FS_NAME_X    10            /* denotes file header      */
#define SIZSTR       16            /* string size in vol header*/
#define DUMNAME      4             /* dummy name length for    */
                                   /* FS_NAME_X                */
#define FXLEN        80            /* length of file index     */