8.2.2 How to Backup the
Current Directory
When you restore information, you are taking information that you backed up in the previous section and using one of the restore methods discussed in the following sections.
For this example, you will restore the file /etc/hosts from a tape device /dev/rmt0.
You can use one of the following commands depending on what command was used to do the backup:
There are three other images (boot image, bosinstall image, and empty table of contents) that precede the backup files in a mksysb. You can move past them using mt or tctl and the no-rewind option on the tape, or you can use the -s4 flag in the restore command.
Rewind the tape to the beginning.
tctl -f /dev/rmt0 rewind
List the information on the backup media.
# restore -T -d -v -q -s4 -f /dev/rmt0.1
New volume on /dev/rmt0.1:
Cluster size is 51200 bytes (100 blocks).
The volume number is 1.
The backup date is: Tue Oct 27 10:15:25 CST 1998
Files are backed up by name.
The user is root.
.......... (Lines Removed)
528 ./tmp/vgdata/rootvg/hd1.map
972 ./tmp/vgdata/rootvg/hd2.map
48 ./tmp/vgdata/rootvg/hd3.map
36 ./tmp/vgdata/rootvg/hd4.map
588 ./tmp/vgdata/rootvg/hd9var.map
0 ./etc
901 ./etc/hosts
0 ./home
0 ./home/lost+found
0 ./home/guest
0 ./home/ftp
254 ./home/ftp/.profile
0 ./home/ftp/bin
18774 ./home/ftp/bin/ls
0 ./home/ftp/etc
0 ./home/ftp/pub
150841 ./home/ftp/pub/aix-1-let.ps
.......... (Lines Removed)
The total size is 509575953 bytes.
The number of archived files is 37773.
This screen scrolls down showing you all the files on the backup medium. If you want to show only the header information, you can leave out the -T and -v flags.
Change to the /etc/ directory and list all files with the word hosts in them. Notice that the hosts file is missing.
# cd /etc # ls -l hosts* -rw-r--r-- 1 root system 2060 Aug 25 09:41 hosts.equiv -rw-rw-r-- 1 root system 1906 Aug 25 09:41 hosts.lpd
Change to the root directory and check your current directory.
# cd / # pwd /
Rewind the tape device.
tctl -f /dev/rmt0 rewind
Restore the file that you want. Notice the . (point) before /etc/hosts; this needs to be part of the restore command.
# restore -x -d -v -q -s4 -f /dev/rmt0.1 ./etc/hosts New volume on /dev/rmt0.1: Cluster size is 51200 bytes (100 blocks). The volume number is 1. The backup date is: Tue Oct 27 10:15:25 CST 1998 Files are backed up by name. The user is root. x 1848 ./etc/hosts The total size is 1848 bytes. The number of restored files is 1.
The information from the tape device during the restore operation is displayed.
Change your directory to /etc and list the files beginning with hosts.
# cd /etc # ls -l hosts* -rw-rw-r-- 1 root system 1848 Sep 10 13:44 hosts -rw-r--r-- 1 root system 2060 Aug 25 09:41 hosts.equiv -rw-rw-r-- 1 root system 1906 Aug 25 09:41 hosts.lpd
Check if the file has been restored.
The following example shows the command syntax you would use to restore the file /etc/hosts using the tar command.
tar -x -v -f /dev/rmt0 /etc/hosts
The following shows the command syntax you would use to restore the file /etc/hosts using the cpio command. Notice that " (quotes) are used in your file selection.
cpio -i -c -v -d -u -m -B < /dev/rmt0 "/etc/hosts"
The next two examples show the command syntax you would use to restore the file /etc/hosts using the restore command.
The following shows how to restore the file /etc/hosts from a backup that was made using the -i flag option during a backup by file name. Notice the -d flag is used to restore the file.
restore -x -d -v -q -f /dev/rmt0 /etc/hosts
The following shows how to restore the file /etc/hosts when a file system backup was used to make the backup.
restore -x -v -q -f /dev/rmt0 /etc/hosts
For this example, you will restore the directory /var and its contents from a tape device /dev/rmt0.
You can use one of the following commands depending on what command was used to do the backup.
Remember there are three other images (boot image, bosinstall image and empty table of contents) that precede the backup files in a mksysb. Move past them using either the mt or tctl commands with the norewind option on the tape or use the -s4 flag option.
Rewind the tape to the beginning.
tctl -f /dev/rmt0 rewind
List the files on the backup media using the restore command:
# restore -T -d -v -q -s4 -f /dev/rmt0.1
New volume on /dev/rmt0.1:
Cluster size is 51200 bytes (100 blocks).
The volume number is 1.
The backup date is: Tue Oct 27 10:15:25 CST 1998
Files are backed up by name.
The user is root.
.......... (Lines Removed)
528 ./tmp/vgdata/rootvg/hd1.map
972 ./tmp/vgdata/rootvg/hd2.map
48 ./tmp/vgdata/rootvg/hd3.map
36 ./tmp/vgdata/rootvg/hd4.map
24 ./tmp/vgdata/rootvg/hd5.map
768 ./tmp/vgdata/rootvg/hd6.map
12 ./tmp/vgdata/rootvg/hd8.map
588 ./tmp/vgdata/rootvg/hd9var.map
0 ./home
0 ./home/lost+found
0 ./home/guest
0 ./home/ftp
254 ./home/ftp/.profile
0 ./home/ftp/bin
18774 ./home/ftp/bin/ls
0 ./home/ftp/etc
0 ./home/ftp/pub
150841 ./home/ftp/pub/aix-1-let.ps
3404039 ./home/ftp/pub/aix-2-let.ps
9210123 ./home/ftp/pub/aix-3-let.ps
4690937 ./home/ftp/pub/aix-6-let.ps
6512370 ./home/ftp/pub/aix-7-let.ps
.......... (Lines Removed)
The total size is 509575953 bytes.
The number of archived files is 37773.
This scrolls down the screen showing you all the files on the backup medium. If you want to show only the header information you can leave out the -T and -v flags.
Change to the /var directory and check present working directory.
# cd /var # pwd /var
List the contents of the current directory:
# ls -l total 13 drwxrwxr-x 8 root adm 512 Oct 22 09:14 adm drwxr-xr-x 2 bin bin 512 Aug 25 16:47 cifs dr-xr-xr-x 3 bin bin 1024 Aug 26 13:37 ifor drwxrwxrwx 2 root system 512 Oct 22 09:15 locks drwx------ 2 root system 512 Aug 25 09:21 lost+found drwxrwxrwx 2 bin bin 512 Aug 25 09:23 msgs drwxrwxrwx 2 bin bin 512 Aug 25 09:23 news drwxrwxrwx 2 bin bin 512 Sep 21 16:40 preserve dr-xr-x--- 2 root system 512 Aug 25 09:39 security drwxrwxr-x 12 bin bin 512 Sep 23 09:09 spool drwxrwxrwt 2 bin bin 512 Oct 27 14:28 tmp
Change directory to the root directory and check the present working directory:
# cd / # pwd /
Rewind the tape and start the directory /var/dt. Notice the . (point) before the directory name; this is always needed when restoring from a mksysb backup:
# tctl -f /dev/rmt0 rewind # restore -x -d -v -s4 -f/dev/rmt0.1 ./var/dt New volume on /dev/rmt0.1: Cluster size is 51200 bytes (100 blocks). The volume number is 1. The backup date is: Tue Oct 27 10:15:25 CST 1998 Files are backed up by name. The user is root. .......... (Lines Removed) x 117 ./var/dt/Xerrors x 5 ./var/dt/Xpid x 44 ./var/dt/A:0-oActaa x 44 ./var/dt/A:0-IdcsMa x 44 ./var/dt/A:0-WqcsMa x 44 ./var/dt/A:0-UzcsUa x 44 ./var/dt/A:0-V7csUa x 44 ./var/dt/A:0-kAcsUa x 44 ./var/dt/A:0-YYcsUa x 44 ./var/dt/A:0-Xoctia .......... (Lines Removed) The total size is 1065 bytes. The number of restored files is 32.
The preceding is the information from the tape device during the restore operation listing all the files restored.
Change your directory to /var and list the contents of the /var directory.
# cd /var # ls -l total 14 drwxrwxr-x 8 root adm 512 Oct 22 09:14 adm drwxr-xr-x 2 bin bin 512 Aug 25 16:47 cifs drwxr-xr-x 4 bin bin 512 Oct 29 10:26 dt dr-xr-xr-x 3 bin bin 1024 Aug 26 13:37 ifor drwxrwxrwx 2 root system 512 Oct 22 09:15 locks drwx------ 2 root system 512 Aug 25 09:21 lost+found drwxrwxrwx 2 bin bin 512 Aug 25 09:23 msgs drwxrwxrwx 2 bin bin 512 Aug 25 09:23 news drwxrwxrwx 2 bin bin 512 Sep 21 16:40 preserve dr-xr-x--- 2 root system 512 Aug 25 09:39 security drwxrwxr-x 12 bin bin 512 Sep 23 09:09 spool drwxrwxrwt 2 bin bin 512 Oct 27 14:28 tmp
Check if the directory /var/dt has been restored.
The following command restores the directory and the directory contents using the tar command:
tar -x -v -f /dev/rmt0 /var/dt
The following command restores the directory and the directory contents using the cpio. command:
cpio -i -c -v -d -u -m -B < /dev/rmt0 "/var/dt/*"
The next two commands shows additional ways to restore a directory and its contents using the restore command.
The following shows how to restore the directory from a filename backup:
restore -x -d -v -q -f /dev/rmt0 /var/dt
The following shows how to restore the directory where a file system backup was done:
restore -x -v -q -f /dev/rmt0 /var/dt
When you need to restore from tape, but the backup was made using an unknown block size, then you need to pipe dd into the restore command.
The error displayed is:
Media Read Error - I/O Error
The following is an example for the file name restore:
# dd if=/dev/rmt0 bs=51200 | restore -xvqf- x 1062769 ./ausnames x 1833056 ./backuplistand 57+0 records in. 57+0 records out.
or
restore -xvqf- </dev/rmt0
This is the example for the i-node restore:
dd if=/dev/rmt0 bs=51200 | restore -xvqmf-
or
restore -xvqmf- </dev/rmt0
The rmfs command removes a file system. You can use this command once you have restored a backup to clean up file systems that are no longer required, or unintentionally mounted during backup time. To run, enter:
rmfs userfs