Backups in Linux Ning Zhu Class presentation. Introduction The dump and restore commands are the...

16
Backups in Linux Ning Zhu Class presentation

Transcript of Backups in Linux Ning Zhu Class presentation. Introduction The dump and restore commands are the...

Page 1: 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.

Backups in Linux

Ning Zhu

Class presentation

Page 2: 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.

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

Page 3: 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.

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

Page 4: 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.

Limitation of dump

• Every filesystem must be dumped individually

• Only filesystems on the local machine can be dumped

Page 5: 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.

Features (dump)

• Support “incremental” backup. Backup level will be assigned to implement this.

• Don’t care about the length of the filenames.

Page 6: 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.

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

Page 7: 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.

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.

Page 8: 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.

Restore the files using restore

• Restore individual files

• Restore entire filesystems

Page 9: 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.

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/nst0restore> lsrestore> cd rdeatonrestore> add lostfilerestore> lsrestore> extract

Page 10: 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.

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

Page 11: 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.

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.

Page 12: 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.

Determine which dumps to restore

0 0 0 0 0 0

0 5 5 5 5

0 3 2 5 4 5

0 9 9 5 9 9 3 9 9 5 9 9

0 3 5 9 3 5 9

Page 13: 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.

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

Page 14: 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.

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.

Page 15: 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.

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.

Page 16: 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.

Other Archiving Programs dd

• dd: twiddle bitsdd 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.