System Administration Guide: Devices and File Systems

Backing Up a File System

The following are general guidelines for performing backups:


Note –

Use the nisbackup command to back up an NIS+ master server. For information on using this command, see System Administration Guide: Naming and Directory Services (FNS and NIS+).


ProcedureHow to Backup a File System to Tape

The following are general steps for backing up file systems by using the ufsdump command. The examples show specific uses of options and arguments.

Steps
  1. Become superuser or assume an equivalent role.

  2. Bring the system to run level S (single-user mode).

    For example:


    # shutdown -g30 -y
    
  3. (Optional) Check the file system for consistency.

    For example:


    # fsck -m /dev/rdsk/c0t0d0s7
    

    The fsck -m command checks for the consistency of file systems. For example, power failures can leave files in an inconsistent state. For more information on the fsck command, see Chapter 20, Checking UFS File System Consistency (Tasks).

  4. If you need to back up file systems to a remote tape drive, follow these steps:

    1. On the system to which the tape drive is attached (the tape server), add the following entry to its /.rhosts file.


      host root

      The host entry specifies the name of the system on which you will run the ufsdump command to perform the backup.

    2. On the tape server, verify that the host added to the /.rhosts file is accessible through the name service.

  5. Identify the device name of the tape drive.

    The default tape drive is the /dev/rmt/0 device.

  6. Insert a tape that is write-enabled into the tape drive.

  7. Back up file systems.


    # ufsdump options arguments filenames
    

    You can back up file systems or directories or files within file systems. For information on backing up individual files, see tar(1) or cpio(1).

    The following examples show how to use the most common ufsdump options and arguments:

    For other ufsdump options and arguments, see Chapter 26, UFS Backup and Restore Commands (Reference).

  8. If prompted, remove the tape and insert the next tape volume.

  9. Label each tape with the volume number, dump level, date, system name, disk slice, and file system.

  10. Bring the system back to run level 3 by pressing Control-D.

  11. Verify that the backup was successful.


    # ufsrestore tf device-name
    

Example 23–3 Performing a Full Backup of root (/)

The following example shows how to do a full backup of the root (/) file system. The system in this example is brought to single-user mode before the backup. The following ufsdump options are included:

For example:


# init 0
ok boot -s
# ufsdump 0ucf /dev/rmt/0 /
  DUMP: Date of this level 0 dump: Tue Oct 07 16:23:08 2003
  DUMP: Date of last level 0 dump: the epoch
  DUMP: Dumping /dev/rdsk/c0t0d0s0 (starbug:/) to /dev/rmt/0.
  DUMP: Mapping (Pass I) [regular files]
  DUMP: Mapping (Pass II) [directories]
  DUMP: Writing 63 Kilobyte records
  DUMP: Estimated 296644 blocks (144.85MB).
  DUMP: Dumping (Pass III) [directories]
  DUMP: Dumping (Pass IV) [regular files]
  DUMP: Tape rewinding
  DUMP: 296224 blocks (144.64MB) on 1 volume at 424 KB/sec
  DUMP: DUMP IS DONE
  DUMP: Level 0 dump on Tue Oct 07 16:23:08 2003
  # ufsrestore tf /dev/rmt/0
         2      .
         3      ./lost+found
      3776      ./usr
      7552      ./var
     11328      ./export
     15104      ./export/home
     18880      ./etc
     22656      ./etc/default
     22657      ./etc/default/sys-suspend
     22673      ./etc/default/cron
     22674      ./etc/default/devfsadm
     22675      ./etc/default/dhcpagent
     22676      ./etc/default/fs
     22677      ./etc/default/inetinit
     22678      ./etc/default/kbd
     22679      ./etc/default/mpathd
     22680      ./etc/default/nfslogd
     22681      ./etc/default/passwd
                .
                .
                .
  # (Press Control-D to bring system to run level 3)


Example 23–4 Performing an Incremental Backup of root (/)

The following example shows how to do an incremental backup of the root (/) file system in single-user mode. The following ufsdump options are included:


# init 0
ok boot -s
.
.
.
Rebooting with command: boot -sSunOS Release 5.9  Generic May 2002
Copyright 1983-2003 Sun Microsystems, Inc.  All rights reserved.
.
.
.
# ufsdump 9ucf /dev/rmt/0 /
 DUMP: Date of this level 9 dump: Mon Oct 06 12:36:10 2003 
 DUMP: Date of last level 0 dump: Wed Oct 08 10:12:13 2003
 DUMP: Dumping /dev/rdsk/c0t0d0s0 (starbug:/) to /dev/rmt/0.
 DUMP: Mapping (Pass I) [regular files]
 DUMP: Mapping (Pass II) [directories]
 DUMP: Writing 63 Kilobyte records
 DUMP: Estimated 335844 blocks (163.99MB).
 DUMP: Dumping (Pass III) [directories]
 DUMP: Dumping (Pass IV) [regular files]
 DUMP: 335410 blocks (163.77MB) on 1 volume at 893 KB/sec
 DUMP: DUMP IS DONE
 DUMP: Level 9 dump on Mon Oct 06 12:36:10 2003
 # ufsrestore tf /dev/rmt/0
         2      .
         3      ./lost+found
      5696      ./usr
     11392      ./var
     17088      ./export
     22784      ./export/home
     28480      ./opt
      5697      ./etc
     11393      ./etc/default
     11394      ./etc/default/sys-suspend
     11429      ./etc/default/cron
     11430      ./etc/default/devfsadm
     11431      ./etc/default/dhcpagent
     11432      ./etc/default/fs
     11433      ./etc/default/inetinit
     11434      ./etc/default/kbd
     11435      ./etc/default/nfslogd
     11436      ./etc/default/passwd
     11437      ./etc/default/tar
                .
                .
                .


Example 23–5 Performing a Full Backup of a Home Directory

The following example shows how to do a full backup of the /export/home/kryten home directory. The following ufsdump options are included:


# umount /export/home

# ufsdump 0ucf /dev/rmt/0 /export/home/kryten
  DUMP: Date of this level 0 dump: Tue Oct 07 08:41:41 2003
  DUMP: Date of last level 0 dump: the epoch
  DUMP: Dumping /dev/rdsk/c0t0d0s0 (starbug:/) to /dev/rmt/0.
  DUMP: Mapping (Pass I) [regular files]
  DUMP: Mapping (Pass II) [directories]
  DUMP: Writing 63 Kilobyte records
  DUMP: Estimated 470 blocks (235KB).
  DUMP: Dumping (Pass III) [directories]
  DUMP: Dumping (Pass IV) [regular files]
  DUMP: 376 blocks (188KB) on 1 volume at 1205 KB/sec
  DUMP: DUMP IS DONE
# ufsrestore tf /dev/rmt/0
         2	    .
         5      ./export
         6      ./export/home
     80799      ./export/home/kryten
     80800      ./export/home/kryten/filea
     80801      ./export/home/kryten/fileb
     80802      ./export/home/kryten/filec
     80803      ./export/home/kryten/letters
     80804      ./export/home/kryten/letters/letter1
     80805      ./export/home/kryten/letters/letter2
     80806      ./export/home/kryten/letters/letter3
     80807      ./export/home/kryten/reports
     80808      ./export/home/kryten/reports/reportA
     80809      ./export/home/kryten/reports/reportB
     80810      ./export/home/kryten/reports/reportC
#


Example 23–6 Performing a Full Backup to a Remote System (Solaris 9 Data to Solaris 9 System)

The following example shows how to do a full backup of a local /export/home file system on a Solaris 9 system (starbug) to a tape device on a remote Solaris 9 system (earth) in single-user mode. The following ufsdump options are included:


# ufsdump 0ucf earth:/dev/rmt/0 /export/home
  DUMP: Date of this level 0 dump: Mon Oct 06 12:46:50 2003
  DUMP: Date of last level 0 dump: the epoch
  DUMP: Dumping /dev/rdsk/c0t0d0s7 (starbug:/export/home) to 
  earth:/dev/rmt/0.
  DUMP: Mapping (Pass I) [regular files]
  DUMP: Mapping (Pass II) [directories]
  DUMP: Writing 63 Kilobyte records
  DUMP: Estimated 410 blocks (205KB).
  DUMP: Dumping (Pass III) [directories]
  DUMP: Dumping (Pass IV) [regular files]
  DUMP: Tape rewinding
  DUMP: 376 blocks (188KB) on 1 volume at 546 KB/sec
  DUMP: DUMP IS DONE
  DUMP: Level 0 dump on Mon Oct 06 12:46:50 2003
 # ufsrestore tf earth:/dev/rmt/0
          2      .
         3      ./lost+found
         4      ./kryten
         5      ./kryten/filea
         6      ./kryten/fileb
         7      ./kryten/filec
         8      ./kryten/letters
         9      ./kryten/letters/letter1
        10      ./kryten/letters/letter2
        11      ./kryten/letters/letter3
        12      ./kryten/reports
.
.
.
 #