Monday, June 25, 2012

Restoring individual file or directory from mksysb image


TO retrieve just one single file from a mksysb image backup.

Go to the directory that contains the mksysb image file

# cd /

Try locating that file in the image first

i.e. the hosts file

# restore -Tqlf myserver.mksysb | grep hosts
    New volume on myserver.mksysb:
    Cluster size is 51200 bytes (100 blocks).
    The volume number is 1.
    The backup date is: Thu Oct  9 23:00:28 MST 2011
    Files are backed up by name.
    The user is padmin.
    -rw-r--r--- 10   root  Sep 23  08:37  2903 ./etc/hosts


Here we see the original file was located in /etc/hosts.

Now recover this file:


# restore -xqf myserver.mksysb ./etc/hosts
    x ./etc/hosts


Please note that it is important to add the dot "." before the filename that needs to be recovered. Otherwise it won't work.

Your file is now restore to ./etc/hosts, which is a relative folder from the current directory you're in right now.

How to restore individual directory from a file name archive


restore -xdvqf /dev/rmt0 /home/mike/tools

A tip here, if you are restoring from file-system archive, remove the 'd' option.

All the files and subdirectories will be extracted to /home/mike/tools. Directories that don't exist will be created.


No comments: