< Day Day Up > |
dump and restoredump and restore are highly functional programs that are used to back up a complete file system and then restore any or all of the file system at a later date. There are some advanced characteristics of these commands that are covered, including the following:
Look at some examples using dump and restore. We'll use several commands in the upcoming examples, including the following: # dump -0u -f /dev/st0 /dev/sda4 ;dump sda4 file system to tape /dev/st0 using level 0 and update /etc/dumpdates. # dump -0uf - /dev/sda4 | gzip --fast -c >> /dev/nst0 ;dump sda4 file system to tape /dev/st0 using level 0 and update /etc/dumpdates. Tape info such as length and density aren't known so send output to std out and gzip before going to tape. # restore -tvf /dev/st0 | grep install.log ;obtain table of contents from tape /dev/st0 and look for file name dump.file # restore -xvf /dev/st0 ./root/install.log ;restore file dump.file current directory Let's take a look at some of these commands in more detail. The first example runs dump to back up /dev/sda4. You set the backup level to 0 for a full backup, the f option to specify the output file /dev/st0, and u for a write to /etc/dumpdates. In the following example, you first issue the df command to view /dev/sda4 (which is roughly 4.8 GB), and then run the dump command: [root@demtstd1 test.cpio]# df Filesystem 1k-blocks Used Available Use% Mounted on /dev/sda4 32253856 4788992 25826464 16% / /dev/sda3 102182 6138 96044 7% /boot/efi none 4158608 0 4158608 0% /dev/shm [root@demtstd1 test.cpio]# dump -0u -f /dev/st0 /dev/sda4 DUMP: Date of this level 0 dump: Wed Mar 5 10:56:17 2003 DUMP: Dumping /dev/sda4 (/) to /dev/st0 DUMP: Added inode 8 to exclude list (journal inode) DUMP: Added inode 7 to exclude list (resize inode) DUMP: Label: / DUMP: mapping (Pass I) [regular files] DUMP: mapping (Pass II) [directories] DUMP: estimated 4721383 tape blocks. DUMP: Volume 1 started with block 1 at: Wed Mar 5 10:56:56 2003 DUMP: dumping (Pass III) [directories] DUMP: dumping (Pass IV) [regular files] DUMP: 14.01% done at 2205 kB/s, finished in 0:30 DUMP: 22.38% done at 1761 kB/s, finished in 0:34 DUMP: 27.69% done at 1452 kB/s, finished in 0:39 DUMP: 33.09% done at 1301 kB/s, finished in 0:40 DUMP: 38.91% done at 1224 kB/s, finished in 0:39 DUMP: 44.23% done at 1160 kB/s, finished in 0:37 DUMP: 49.69% done at 1117 kB/s, finished in 0:35 DUMP: 59.78% done at 1175 kB/s, finished in 0:26 DUMP: 65.21% done at 1140 kB/s, finished in 0:24 DUMP: 70.54% done at 1110 kB/s, finished in 0:20 DUMP: 77.40% done at 1107 kB/s, finished in 0:16 DUMP: 82.73% done at 1084 kB/s, finished in 0:12 DUMP: 90.04% done at 1090 kB/s, finished in 0:07 DUMP: Closing /dev/st0 DUMP: Volume 1 completed at: Wed Mar 5 12:07:15 2003 DUMP: Volume 1 4804230 tape blocks (4691.63MB) DUMP: Volume 1 took 1:10:19 DUMP: Volume 1 transfer rate: 1138 kB/s DUMP: 4804230 tape blocks (4691.63MB) on 1 volume(s) DUMP: finished in 4175 seconds, throughput 1150 kBytes/sec DUMP: Date of this level 0 dump: Wed Mar 5 10:56:17 2003 DUMP: Date this dump completed: Wed Mar 5 12:07:15 2003 DUMP: Average transfer rate: 1138 kB/s DUMP: DUMP IS DONE dump provides information related to the backup to standard output. There are regular status outputs reported. We used the -u option, which updates the /etc/dumpdates file: [root@demtstd1 test.cpio]# cat /etc/dumpdates /dev/sda4 0 Wed Mar 5 10:56:17 2003 [root@demtstd1 test.cpio]# Because we used the u option, we will get an entry in /etc/dumpdates for every file system that was dumped. In this case, we dumped only /dev/ sda4. Next, extract the file install.log from the dump and view its contents. To extract the file from tape, use the x option to restore, as shown in the following listing: # restore -xvf /dev/st0 ./root/install.log Verify tape and initialize maps Input is from tape Tape block size is 10 Dump date: Wed Mar 5 10:56:17 2003 Dumped from: the epoch Level 0 dump of / on demtstd1.ct.pb.com:/dev/sda4 Label: / Extract directories from tape Initialize symbol table. restore: ./root: File exists Extract requested files You have not read any tapes 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 ./root/install.log Add links Set directory mode, owner, and times. set owner/mode for '.'? [yn] n [root@demtstd1 root]# more install.log Installing 509 packages Installing glibc-common-2.2.4-27.2. Installing indexhtml-7.2-1. Installing mailcap-2.1.6-1. Installing redhat-logos-1.1.3-1. Installing sash-3.4-11. Installing setup-2.5.7-1. Installing filesystem-2.1.6-2. Installing basesystem-7.0-2. Installing glibc-2.2.4-27.2. Installing bdflush-1.5-17. Installing bzip2-libs-1.0.1-4. Installing chkconfig-1.2.24-1. Installing cracklib-2.7-12. Installing db1-1.85-7. Installing db2-2.4.14-9. Installing db3-3.3.11-5. Installing dosfstools-2.7-1. Installing e2fsprogs-1.26-1.72. Installing eject-2.0.9-2. Installing elilo-3.2-4 [root@demtstd1 root]# Notice that as part of restoring the file, we had to specify a volume number of 1 and decide whether we wanted to set the mode for the file. Also note that the restore took place with a relative path name. To get a table of contents from the tape, you would have used -t. Another commonly used option with restore is -i, which performs an interactive restore that was not part of the example. You could also create a file that automatically performs several file system backups for you. dump creates a large file for file system that is part of the backup. That means that you can put multiple file systems on a backup tape. You have been using a tape device file of /dev/st0, which is a rewind tape device. Because you want to put multiple tapes on the file, use a no rewind device of /dev/nst0. When you use the mount command, mt, you can control this tape drive using options such as rewind and eject. Since the length of the tape and density aren't known, run dump commands and pipe the output to gzip, which gives you some compression. The following file that we'll cat called dump.file contains these commands: # cat dump.file mt -f /dev/nst0 rewind dump -0uf - /dev/sda | gzip --fast -c > /dev/nst0 #fill in other file systems /dev/sdx mt -f /dev/nst0 rewind mt -f /dev/nst0 eject You have only one file system to backup on your system, but you could add dump lines for all of your file systems. First, mount the tape with mt. Next, run the dump commands and pipe them to gzip with the --fast option to make the backup go much faster; however, the compression is not as dense as without this option. You also get gzip output to standard output with -c. You're going to dump only /dev/sda in the example but you could add additional lines. When you run the file, it will perform the dumps. The following example shows multiple lines on an IA-32 system with IDE drives: # cat dump.file mt -f /dev/nst0 rewind dump -0uf - /dev/hda1 | gzip --fast -c > /dev/nst0 #dump -0uf - /dev/hda2 | gzip --fast -c > /dev/nst0 #dump -0uf - /dev/hda3 | gzip --fast -c > /dev/nst0 #dump -0uf - /dev/hda5 | gzip --fast -c > /dev/nst0 dump -0uf - /dev/hda6 | gzip --fast -c > /dev/nst0 #dump -0uf - /dev/hdb1 | gzip --fast -c > /dev/nst0 mt -f /dev/nst0 rewind mt -f /dev/nst0 eject Keep in mind that you can only use such a procedure if you're sure the files you dump will fit on a single tape because without specifying tape density and length, you won't get a multi-tape backup. To see all the options for the commands used in this section, look at the man pages for mt, dump, gzip, and restore. |
< Day Day Up > |