Back to the main page

UFS dump and restore

Backing UFS file system

A UFS file system can be backed up using command ufsdump. 

Note that you should use it on unmounted or read-only FS. 
Even better, you can first create snapshot of FS (read only copy of FS) and use ufsdump on snapshot. 

Check how to work with  UFS snapshots . 
 
The command ufsdump has many options so you better read man page.

Probably first thing you want to do is to determine size of your backup, say you need to know how many tapes you need, if you backup on tapes. 
# ufsdump -S /my-filesystem
30567424
Note: the size is in bytes !! Say, I am doing: 1. full backup (option 0). 1-9 is for incremental backups. 2. record info in /etc/dumpdates file (option u) 3. use option 'a' to archive dump table of content to binary file named "archive-file" so ufsrestore can determine whether a file to be restored is in dump file 4. dump FS to the file fs-dump.
# ufsdump 0uaf archive-file fs-dump /my-filesystem
  DUMP: Date of this level 0 dump: December 2, 2009 11:44:19 AM PST
  DUMP: Date of last level 0 dump: the epoch
  DUMP: Dumping /dev/rdsk/c1t0d0s4 (hostname:/my-filesystem) to fs-dump.
  DUMP: Mapping (Pass I) [regular files]
  DUMP: Mapping (Pass II) [directories]
  DUMP: Writing 32 Kilobyte records
  DUMP: Estimated 44732 blocks (21.84MB).
  DUMP: Dumping (Pass III) [directories]
  DUMP: Dumping (Pass IV) [regular files]
  DUMP: 44670 blocks (21.81MB) on 1 volume at 1720 KB/sec
  DUMP: Archiving dump to `archive-file`
  DUMP: DUMP IS DONE
  DUMP: Level 0 dump on December 2, 2009 11:44:19 AM PST
Check the file /etc/dumpdates. Should have the line:
/dev/rdsk/c1t0d0s4    0 Wed Dec 2 11:44:19 2009
Note: beside FS name (like /my-filesystem), you can also use something like /dev/dsk/c1t0d0s4 or /dev/rdsk/c1t0d0s3.

Restoring UFS file system

The command ufsrestore restores complete FS or individual files. 

Note 1: ufsrestore restores backup hierarchy in the current directory. 

Note 2: even temporarily, do not restore files in /tmp directory (usually it is mounted as TMPFS and does not support UFS FS attributes, like ACL)

Say, you want to restore individual file(s). 

In order to find them in backup (file or tape), list content of backup (using "t"). 
In this case it is good having dump archive file (created with ufsdump command). 

Note: I am in the directory where archive-file is located. 
# ufsrestore ta archive-file
         2      .
        78      ./139434-01
        79      ./139434-01/copyright
        80      ./139434-01/Install.info
        81      ./139434-01/LEGAL_LICENSE.TXT
        82      ./139434-01/README.139434-01  
	Etc etc etc
If list is long, grep for what you need.
# ufsrestore ta archive-file | grep Install
        80      ./139434-01/Install.info
        92      ./1/Install.info
       104      ./2/Install.info
       116      ./3/Install.info
       128      ./4/Install.info
       140      ./5/Install.info
Or if you look for specific file, look only for it. Note: you must specify whole path.
# ufsrestore ta archive-file ./3/Install.info
116	./3/Install.info
Restoring files interactively (option "i") Say, go to /var/tmp directory and restore file there. Note I type full path of 'backup file' /backup/fs-dump.
# /var/tmp> ufsrestore if /backup/fs-dump
ufsrestore > help comment: use help to find available commands
Available commands are:
        ls [arg] - list directory
        marked [arg] - list items marked for extraction from directory
        cd arg - change directory
        pwd - print current directory
        add [arg] - add `arg' to list of files to be extracted
        delete [arg] - delete `arg' from list of files to be extracted
        extract - extract requested files
        setmodes - set modes of requested directories
        quit - immediately exit program
        what - list dump header information
        verbose - toggle verbose flag (useful with ``ls'')
        paginate - toggle pagination flag (affects ``ls'' and ``marked'')
        setpager - set pagination command and arguments
        help or `?' - print this list
If no `arg' is supplied, the current directory is used
ufsrestore > ls
.:
 3/                            
 4/                            
 5/                                                    
ufsrestore > cd 4
ufsrestore > ls
./4:
 Install.info
 LEGAL_LICENSE.TXT
 README.139434-01
 copyright
ufsrestore > add Install.info comment: add files to restore
ufsrestore > ls
./4:
*Install.info
 LEGAL_LICENSE.TXT
 README.139434-01
ufsrestore > what comment: get some more info
Dump   date: December  2, 2009 12:25:08 PM PST
Dumped from: the epoch
Level 0 dump of /my-filesystem on hostname:/dev/dsk/c1t0d0s4
Label: none
ufsrestore > extract comment: extract/restore selected files
You have not read any volumes yet.
Unless you know which volume your file(s) are on you should start
with the last volume and work towards the first.
Specify next volume #: 1 comment: in most cases is volume 1
set owner/mode for '.'? [yn] n comment: NO when restoring in directory other then one from which files were dumped
			       comment: YES if restoring in same directory from were dump was performed.
ufsrestore > quit
Check restored files.
# /var/tmp> cd 4

# /var/tmp/4> ls
total 28
drwxr-xr-x   2 root     root         512 Nov 20 12:03 .
drwxrwxrwt   3 root     sys          512 Dec  2 13:36 ..
-rw-r--r--   1 root     root       12035 Dec 18  2008 Install.info comment: okay, file is here
Restoring files non-interactively (option 'x') Say, you already know what you want to restore and know exact 'backup' path of the file(s). I also type full path of backup file (/backup/fs-dump).
# ufsrestore xvf /backup/fs-dump ./5/sysfwdownload ./5/sysfwdownload.README
Verify volume and initialize maps
Media block size is 126
Dump   date: December  2, 2009 12:25:08 PM PST
Dumped from: the epoch
Level 0 dump of /my-filesystem on hostname:/dev/dsk/c1t0d0s4
Label: none
Extract directories from tape
Initialize symbol table.
Make node ./5
Extract requested files
You have not read any volumes yet.
Unless you know which volume your file(s) are on you should start
with the last volume and work towards the first.
Specify next volume #: 1
extract file ./5/sysfwdownload
extract file ./5/sysfwdownload.README
Add links
Set directory mode, owner, and times.
set owner/mode for '.'? [yn] n
Restoring complete FS (option 'r') Say, drive is gone and you want to restore FS that was there. So you: 1. Replace the drive 2. Create the new FS (with newfs) 3. Mount to temporarily mount point, like /mnt 4. Go to /mnt directory 5. Restore FS like below
# ufsrestore rvf /backup/fs-dump
Verify volume and initialize maps
Media block size is 126
Dump   date: December  2, 2009 12:25:08 PM PST
Dumped from: the epoch
Level 0 dump of /my-filesystem on hostname:/dev/dsk/c1t0d0s4
Label: none
Begin level 0 restore
Initialize symbol table.
Extract directories from tape
Calculate extraction list.
Make node ./139434-01
Make node ./cs2
Make many nodes, etc, etc
Extract new leaves.
Check pointing the restore
extract file ./hsperfdata_root-ttt/382
extract file ./ogl_select209
extraxt many files, etc, etc
Add links
Set directory mode, owner, and times.
Check the symbol table.
Check pointing the restore
6. Verify restored files with command ls 7. There is file /mnt/restoresymtable. Delete it. 8. Go to / (cd /) 9. Unmount restored FS (unmount /mnt) 10.Mount 'old' FS (in file /etc/vfstab enable line: /dev/dsk/c1t0d0s4 /dev/rdsk/c1t0d0s4 /.0 ufs 2 yes -) Note: if you are restoring root FS (/) you need to install bootblock, like: # /usr/platform/SUNW,UltraAX-i2/lib/fs/ufs> installboot bootblk /dev/rdsk/c1t0d0s0
Back to the main page