• No results found

Working with “dump/restore”

In document linux (Page 118-121)

22. Backups

22.6 Working with “dump/restore”

The “dump” handles a physical filesystem as an archiving target and the restore command usually uses the archive to restore the filesystem as it was dumped. Each file is managed by the i-node number and, basically, dump cannot exclude specific files from the archive.

Dump is indeed a simplistic and primitive tool, but it does come with a brilliant feature for incremental archiving. It identifies newly created or modified files after the previous backup and efficiently stores them to an archive very fast.

For example, suppose a file `foo' was backed up during the last archiving and removed afterwards. On the next incremental archiving, dump puts the record in the archive as `there used to be a file foo, but it was removed'. If you use tar for your regular incremental backup tasks and attempt a full restoration one day, you may run out of the disk space by trying to restore a large number of files that had already been removed. With dump, you will never face such a problem.

In summary, it would be fair to say cpio, tar or afio is suitable for archiving specific files or directories.

Note: Dump is suitable for archiving whole filesystems and is Not Recommended for Mounted File Systems!

Tape Device files

The Linux kernel provides the drivers for the tape devices. Please build the proper driver for your device when compiling your kernel. You may also use loadable module, if you prefer.

Then, check the device files.

% ls -l /dev/*st[0-9]

Linux Administration – Backups Page 119 of 167 command). st? are ``auto-rewind'' devices, which rewind the tape after the command is invoked to the driver, and nst? are ``no-rewind'' devices. Which to use is your choice, but I prefer the no rewind ones. In this document, /dev/nst0 is used as the target device. When the target device is chosen, you may want to create the symlink to it named ``/dev/tape''. With this, you can omit the device name on the command lines of mt and others.

% cd /dev; ln -s nst0 tape

If you intend to use the tape drive for the backup only, you should consider limiting the access to it. To do this, remove the read/write permissions for `Others'. In the above example, the first tape drive is accessible to normal users, and the second drive is backup purposes only, to which the access is prohibited except for the owner and the users belonging to the `disk' group.

22.6.1 Making backups with dump

following parameters should be the order: dump sbf `tape length' `blocksize' `filesystem' `output file'

- filesystem

mount point or a device name of the filesystem to dump

It's interesting to use the dump backup program if you want to take advantage of its several levels of backup procedures. Given below is a procedure to have a longer backup history and to keep both the backup and restore times to a minimum. In the following example, we assume that the backup is written to a tape drive named /dev/st0 and we backup the home directory /home of our system.

It is important to always start with a level 0 backup, for example:

[root@skynet] /# dump -0u -f /dev/st0 /home

DUMP: Date of this level 0 dump: Fri Jan 28 21:25:12 2000 DUMP: Date of last level 0 dump: the epoch

DUMP: Dumping /dev/sda6 (/home) to /dev/st0 DUMP: mapping (Pass I) [regular files]

DUMP: mapping (Pass II) [directories]

DUMP: estimated 18582 tape blocks on 0.48 tape(s).

DUMP: Volume 1 started at: Fri Jan 28 21:25:14 2000 DUMP: dumping (Pass III) [directories]

DUMP: dumping (Pass IV) [regular files]

DUMP: DUMP: 18580 tape blocks on 1 volume(s)

DUMP: finished in 4 seconds, throughput 4645 KBytes/sec DUMP: Volume 1 completed at: Fri Jan 28 21:25:18 2000 DUMP: Volume 1 took 0:00:04

DUMP: Volume 1 transfer rate: 4645 KB/s

Linux Administration – Backups Page 120 of 167

www.wilshiresoft.com Wilshire Software Technologies Rev Dt: 15-Oct-08 DUMP: level 0 dump on Fri Jan 28 21:25:12 2000

DUMP: DUMP: Date of this level 0 dump: Fri Jan 28 21:25:12 2000 DUMP: DUMP: Date this dump completed: Fri Jan 28 21:25:18 2000 DUMP: DUMP: Average transfer rate: 4645 KB/s

DUMP: Closing /dev/st0 DUMP: DUMP IS DONE

-0 to -9 is the backup level option you want to use, the u option means to update the file /etc/dumpdates after a successful dump, the -f option to write the backup to file

The file may be a special device file like /dev/st0, a tape drive, /dev/rsd1c, a disk drive Finally, you must specify what you want to backup. In our example, it is the /home directory /home.

The full backup should be done at set intervals, say once a month, and on a set of fresh tapes that are saved forever. With this kind of procedure, you will have 12 tapes for 12 months that handle histories and changes of your system for one year. Later, you can copy the 12 tape backups onto a different computer designated to keep all yearly backups for a long time and be able to reuse them, 12 tapes, to repeat the procedure for a new year.

22.6.2 Restoring files with “restore” command

The restore command performs the inverse function of dump(8). It restores files or file systems from backups made with dump. A full backup of a file system may be restored, and subsequent incremental backups layered on top of it. Single files and directory sub-trees may be restored from full, or partial backups. You have a number of possibile commands and options to restore backed up data with the dump program. Below, detailed is a procedure that uses the full potential of the restore program with the most options possible. It is also done in interactive mode.

In an interactive restoration of files from a dump, the restore program provides a shell like interface that allows the user to move around the directory tree selecting files to be extracted, after reading in the directory information from the dump. The following is what we will see if we try to restore our /home directory:

First of all, with the following command we must move to the partition file system where we want to restore our backup. This is required, since the interactive mode of the restore program will restore our backups from the current partition file system where we have executed the restore command.

[root@skynet] /# cd /home

To restore files from a dump in interactive mode, use the following command:

[root@skynet /home]# restore -i -f /dev/st0 restore >

A prompt will appear in your terminal, to list the current, or specified, directory. Use the ls command as shown below:

restore > ls .:

admin/ lost+found/ named/ quota.group quota.user accounts/

restore >

To change the current working directory to the specified one, use the cd commands. In our example, we change to accounts directory, as shown below:

restore > cd accounts specified, then it and all its descendents are added to the extraction list as shown below:

restore > add Personal/

Files that are on the extraction list are prepended with a * when they are listed by the ls command:

restore > ls ./accounts:

Linux Administration – Backups Page 121 of 167 .Xdefaults .bash_logout .bashrc

.bash_history .bash_profile *Personal/

To delete the current directory or specified argument from the list of files to be extracted, use the delete command. If a directory is specified, then all its descendents including itself are deleted from the extraction list, as shown below:

restore > cd Personal/

restore > ls

./accounts/Personal:

*Ad?le_Nakad.doc *Overview.doc

*BIMCOR/ *Resume/

*My Webs/ *SAMS/

*Contents.doc *Templates/

*Divers.doc *bruno universite.doc

*Linux/ *My Pictures/

restore > delete Resume/

restore > ls

./accounts/Personal:

*Ad?le_Nakad.doc *Overview.doc

*BIMCOR/ Resume/

*My Webs/ *SAMS/

*Contents.doc *Templates/

*Divers.doc *bruno universite.doc

*Linux/ *My Pictures/

The most expedient way to extract most of the files from a directory is to add the directory to the extraction list and then delete those files that are not needed.

To extract all files in the extraction list from the dump, use the extract command. Restore will ask which volume the user wishes to mount. The fastest way to extract a few files is to start with the last volume and work towards the first volume, as shown below:

restore > extract 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 set owner/mode for '.'? [yn] y

To exit from the interactive restore mode after you have finished extracting your directories or files, use the quit command as shown below.

/sbin/restore > quit

Other methods of restoration exist with the dump program, consult the man page of dump for more information.

Further documentation, for more details, there are man pages you can read:

dump(8)and restore(8).

In document linux (Page 118-121)