420 likes | 929 Views
Backups in Linux . Ning Zhu Class presentation. Introduction. The dump and restore commands are the most common way to create and restore from backups in Linux Some other programs also can be used to backup the files. Such as: tar , cpio and dd. Advantage of dump.
E N D
Backups in Linux Ning Zhu Class presentation
Introduction • The dump and restore commands are the most common way to create and restore from backups in Linux • Some other programs also can be used to backup the files. Such as: tar, cpio and dd
Advantage of dump • Backups can span multiple tapes • Files of any type can be backed up and restored • Permissions, ownerships, and modification times are preserved • Files with holes are handled correctly • Backups can be performed incrementally
Limitation of dump • Every filesystem must be dumped individually • Only filesystems on the local machine can be dumped
Features (dump) • Support “incremental” backup. Backup level will be assigned to implement this. • Don’t care about the length of the filenames.
flags to dump • -u: causes dump to automatically update /etc/dumpdates when the dump completes. The date, dump level and filesystem name are recorded. • -f: indicates where dump sends the output • -B: tells dump what is the tape length can be used to dump the files. # dump -5u –B 800000 –f /dev/sto /work
Dump Schedule • Simple schedule: Do level 0 dumps of every filesystem each day. Reuse a group of tapes, but every N days, keep the tape forever. • Moderate schedule: assign a tape to each day of the week, each week of the month, and each month of the year. Every day, do a level 9 dump to the daily tape. Every week, do the level 5 dump. And every month, do a level 3 dump. Do a level 0 dump whenever the incrementals get too big to fit on one tape.
Restore the files using restore • Restore individual files • Restore entire filesystems
Restoring individual files Restore the file /users/rdeaton/lostfile from a remote tape drive for user Dr. Deaton: # mkdir /var/restore # cd /var/restore # rsh tapehost mt –f /dev/nst0 fsf 3 # rrestore –i –f tapehost:/dev/nst0 restore> ls restore> cd rdeaton restore> add lostfile restore> ls restore> extract
Restoring individual files (cont’) Give the file to rdeaton: # cd /var/restore # ls rdeaton # ls ~rdeaton # cp –p rdeaton/lostfile ~rdeaton/lostfile.restored # chown rdeaton ~rdeaton/lostfile.restored # rm –rf /var/restore # mail rdeaton Your file lostfile has been restored and has been placed in /users/rdeaton/lostfile.restored
Restoring entire filesystems • Create and mount the target filesystem • cd to the mount point of the new filesystem • Put the most recent level 0 dump in the tape drive • Type restore –r • After the level 0 dump has been restored, mount and restore the incremental dumps.
Determine which dumps to restore 0 0 0 0 0 0 0 5 5 5 5 0 3 2 5 45 0 9 9 5 9 9 3 9 9 5 9 9 0 3 5 9 359
Restore expamle If the most recent dump was the first monthly after the annual level 0 in the “moderate” schedule, the commands to restore /home, residing on the physical device /dev/sda1 # /etc/mke2fs /dev/sda1 QUANTUM_PD1050S # /etc/mount /dev/sda1 /home # cd /home /* mount first tape of level 0 dump of /home */ # restore –r /* mount first tape of level 3 monthly dump */ # restore –r
Other Archiving Programs tar • tar: package files tar reads multiple files or directories and packages them into one file, often a tape file. tar is useful way to back up any files whose near-term recovery you anticipate.
Other Archiving Programs cpio • cpio: archiving utility from ancient times cpio is similar to tar in functionality. It’s rarely used today. Like tar, cpio can be used to move directory trees.
Other Archiving Programs dd • dd: twiddle bits dd is a file copying and conversion program. dd just copies from its input file to its output file. If a user brings you a tape that was written on some non-Linux system, dd may be the only way to read it. dd was to create a copy of an entire system. However, restore and dump is a better option these days.