IBM Support

Restoring specific file from mksysb

Question & Answer


Question

How do I restore specific file from mksysb ?

Answer

This document will guide you through the steps of restoring file from mksysb. In case you run into any problems during this operation please open new case with IBM Support Team for further investigation.
This topic will be covered in the following parts:
Important: Because the files backed up in the mksysb are backed up with relative path. This means that on restore, we will try to restore the relative path structure the files have on backup.
If you restore a file from the / directory, based on its relative path it will overwrite the file that is currently on the system (provided one exists). That's why you should always restore files from a different directory than /. For example of this you may see the Common mistakes section.
Restoring file from mksysb residing locally
First go to the directory that contains the mksysb image file:
# cd /export/mksysb
Then locate the file you are looking for, for example the filename is test.file:
# restore -Tqvf mksysb.11042020 | grep test.file
New volume on mksysb.11042020:
 Cluster 51200 bytes (100 blocks).
    Volume number 1
    Date of backup: Wed Nov  4 06:00:36 2020
    Files backed up by name
    User root
        7351 ./tmp/test.file
    files archived: 44767

    
Here you can see that the test.file was located in /tmp directory of the mksysb.
Now to restore that file:
# restore -xqvf mksysb.11042020 ./tmp/test.file
New volume on mksysb.11042020:
 Cluster 51200 bytes (100 blocks).
    Volume number 1
    Date of backup: Wed Nov  4 06:00:36 2020
    Files backed up by name
    User root
x         7351 ./tmp/test.file
    total size: 7351
    files restored: 1
Please keep in mind that it is very important to add dot before the filename that needs to be restored.

Your file is now restored inside the current working directory /export/mksysb/ and it is located in /export/mksysb/tmp/test.file
# ls -l /export/mksysb/tmp/test.file
-rw-r--r--    1 root     system         7351 Nov  4 05:53 /export/mksysb/tmp/test.file
Restoring file from mksysb on tape

First rewind the tape:
# tctl -f /dev/rmt0 rewind
Then create new directory where you will restore the file and cd inside it:
# mkdir -p /home/filerestore
# cd /home/filerestore
Locate the file you are looking for, for example the filename is test.file:
# restore -Tqvf /dev/rmt0 | grep test.file
New volume on /dev/rmt0:
 Cluster 51200 bytes (100 blocks).
    Volume number 1
    Date of backup: Wed Nov  4 06:00:36 2020
    Files backed up by name
    User root
        7351 ./tmp/test.file
    files archived: 44767

    
Here you can see that the file was located in /tmp directory of the mksysb.
Now to restore that file:
# restore -xqvf /dev/rmt0 ./tmp/test.file
New volume on /dev/rmt0:
 Cluster 51200 bytes (100 blocks).
    Volume number 1
    Date of backup: Wed Nov  4 06:00:36 2020
    Files backed up by name
    User root
x         7351 ./tmp/test.file
    total size: 7351
    files restored: 1

    
Please keep in mind that it is very important to add dot before the filename that needs to be restored.

Your file is now restored inside the current working directory /home/filerestore and it is located in /home/filerestore/tmp/test.file
# ls -l /home/filerestore/tmp/test.file
-rw-r--r--    1 root     system         7351 Nov  4 05:53 /home/filerestore/tmp/test.file
Restoring file from mksysb on USB/DVD

First create new directory where you will restore the file and cd inside it:
# mkdir -p /home/filerestore
# cd /home/filerestore
Locate the file you are looking for, for example the filename is test.file:
# restore -Tqvf /dev/usbms0 | grep test.file
New volume on /dev/usbms0:
 Cluster 51200 bytes (100 blocks).
    Volume number 1
    Date of backup: Wed Nov  4 06:00:36 2020
    Files backed up by name
    User root
        7351 ./tmp/test.file
    files archived: 44767
For mksysb on DVD:
# restore -Tqvf /dev/cd0 | grep test.file
New volume on /dev/cd0:
 Cluster 51200 bytes (100 blocks).
    Volume number 1
    Date of backup: Wed Nov  4 06:00:36 2020
    Files backed up by name
    User root
        7351 ./tmp/test.file
    files archived: 44767

    
Here you can see that the file was located in /tmp directory of the mksysb.
Now to restore that file:
# restore -xqvf /dev/usbms0 ./tmp/test.file
New volume on /dev/usbms0:
 Cluster 51200 bytes (100 blocks).
    Volume number 1
    Date of backup: Wed Nov  4 06:00:36 2020
    Files backed up by name
    User root
x         7351 ./tmp/test.file
    total size: 7351
    files restored: 1
For mksysb on DVD:
# restore -xqvf /dev/cd0 ./tmp/test.file
New volume on /dev/cd0:
 Cluster 51200 bytes (100 blocks).
    Volume number 1
    Date of backup: Wed Nov  4 06:00:36 2020
    Files backed up by name
    User root
x         7351 ./tmp/test.file
    total size: 7351
    files restored: 1

    
Please keep in mind that it is very important to add dot before the filename that needs to be restored.

Your file is now restored inside the current working directory /home/filerestore and it is located in /home/filerestore/tmp/test.file
# ls -l /home/filerestore/tmp/test.file
-rw-r--r--    1 root     system         7351 Nov  4 05:53 /home/filerestore/tmp/test.file

Common mistakes
    
Using / as current working directory will overwrite the file you are extracting/restoring if there is the same filename and path currently on the system.
Example:
# cd /
# pwd
/
# restore -xqvf /export/mksysb/mksysb.11042020 ./tmp/test.file
New volume on /export/mksysb/mksysb.11042020:
 Cluster 51200 bytes (100 blocks).
    Volume number 1
    Date of backup: Wed Nov  4 06:00:36 2020
    Files backed up by name
    User root
x         7351 ./tmp/test.file
    total size: 7351
    files restored: 1

# ls -l /tmp/test.file
-rw-r--r--    1 root     system         7351 Nov  4 05:53 /tmp/test.file
If you run into any problems please open new case with IBM Support Team for further investigation.
References:

[{"Line of Business":{"code":"LOB08","label":"Cognitive Systems"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SWG10","label":"AIX"},"ARM Category":[{"code":"a8m0z000000cvyjAAA","label":"Install->mksysb\/backups"}],"ARM Case Number":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Version(s)"}]

Document Information

Modified date:
04 November 2020

UID

ibm16359521