11
Backup Linux System Administration 1 Linux System Administration System Backup Strategies Backup Linux System Administration 2 Objective At the conclusion of this module, the student will be able to: describe the necessity for creating a backup regimen describe the advantages and disadvantages of the most commonly used backup devices describe the basic syntax and usage of the dump and restore commands use the dump command to archive a filesystem explain the limitations of the dump command and precautions for its use describe the advantages of different backup sequences restore an individual file from a filesystem archive restore an entire filesystem from an archive describe various archiving options available on UNIX systems

Linux System Administration - ux.brookdale.cc.nj.usux.brookdale.cc.nj.us/fac/engtech/andy/netw110/powerpoint/week11... · Backup Linux System Administration 3 Backup Linux System

Embed Size (px)

Citation preview

Page 1: Linux System Administration - ux.brookdale.cc.nj.usux.brookdale.cc.nj.us/fac/engtech/andy/netw110/powerpoint/week11... · Backup Linux System Administration 3 Backup Linux System

Backup Linux System Administration

1

Linux System Administration

System Backup Strategies

Backup Linux System Administration 2

ObjectiveAt the conclusion of this module, the student will be able to:• describe the necessity for creating a backup regimen • describe the advantages and disadvantages of the most

commonly used backup devices • describe the basic syntax and usage of the dump and restore

commands • use the dump command to archive a filesystem • explain the limitations of the dump command and precautions

for its use • describe the advantages of different backup sequences • restore an individual file from a filesystem archive • restore an entire filesystem from an archive • describe various archiving options available on UNIX systems

Page 2: Linux System Administration - ux.brookdale.cc.nj.usux.brookdale.cc.nj.us/fac/engtech/andy/netw110/powerpoint/week11... · Backup Linux System Administration 3 Backup Linux System

Backup Linux System Administration

2

Backup Linux System Administration 3

Designing a Backup Strategy• In designing a backup strategy, we should ask:

1. What happens if I loose my data ? • For a bank consider what happens if they lose an atm withdrawal?

2. How long can we afford to be down if we have to recover data from archive?

3. Could our organization function if we were down for a day or more while data is restored?

• If you must have guaranteed access to data you might consider using some form of RAID disk storage

• RAID storage, coupled with optical or tape backup can deliver almost continuous uptime

Backup Linux System Administration 4

Backup Responsibility• It is necessary to develop a thorough, and easily maintained backup

procedure • The first step in designing a backup strategy is to create a written policy

that specifies: – who is responsible for ensuring that backups occur– what file systems and files need regular archiving

• Anything that is mission critical for the organization should be backed up regularly– when backups be performed

• Backups should be conducted during slow hours because most backup programs will not properly archive a file if it is in use

• The policy should specify a backup time and all users should know the schedule– where the backup tapes and media should be stored

• This should be a secure, cool, and dry place• Some critical backups should be stored off campus

– which systems need backing up• Decide which systems require a regular backup and the frequency

– what type of media should be used for backing up– how to backup

Page 3: Linux System Administration - ux.brookdale.cc.nj.usux.brookdale.cc.nj.us/fac/engtech/andy/netw110/powerpoint/week11... · Backup Linux System Administration 3 Backup Linux System

Backup Linux System Administration

3

Backup Linux System Administration 5

What to Backup• As a backup policy is developed make a decision on what

needs to be backed up• Differentiate between the operating system files and user files• We need to archive the operating system (including /, /usr,

/var, and /etc) only when significant changes occur• We need to backup user files in /home much more frequently

– Since these directories may become very large, so we should schedule backups at off-peak times

• Usually Friday, Saturday, or Sunday nights for full backups– Develop a strategy that backs up only those files that have changed

since the last backup

Backup Linux System Administration 6

Backup Strategy • Full

– aka level 0, archival, or epochal– a complete archive of all files, including system and user files– requires one set of media, but takes the longest time– the mandatory part of all other strategies– may be done on a weekly, monthly or quarterly basis

• frequency depends on how often system files are updated.• Differential

– Backup of all files that were created or modified since the last full backup

– requires two sets of tapes• The first tape contains the full backup• The second contains a backup of all files created or changed since the full

backup• This option saves backup time, but requires more time to restore

Page 4: Linux System Administration - ux.brookdale.cc.nj.usux.brookdale.cc.nj.us/fac/engtech/andy/netw110/powerpoint/week11... · Backup Linux System Administration 3 Backup Linux System

Backup Linux System Administration

4

Backup Linux System Administration 7

Backup Strategy • Incremental

– This is more a complex method – uses several sets of tapes to archive only those files with newer created

or modified dates since the last backup– A new tape is used for each backup– Each new tape contains only files created or changed on the day of the

backup– When restoring, we must use the archival tape, then restore each tape

for each day– This option allows us to spend the least time backing up, but requires

the most time when restoring– Incremental backups pose the threat of operator error

• Network backup– backing up filesystems from one machine onto a backup device

connected to another machine– referred to as a remote or network backup

Backup Linux System Administration 8

Disk Mirroring• Disk Mirroring

– duplicates everything on one drive to another drive– It is usually common for a system of this type to update the duplicate

drive continuously with the most current information• With RAID 1, the duplicate drive is written at the same time as the original• This reduces or eliminates the recovery time in case of a disaster

– Many popular repositories of shareware and free software, like Tucows, uses disk mirroring

– It also reduces incoming traffic since users can visit a local mirror (in New Jersey, one of the Tucows mirrors is at Rutgers) to downloadsoftware

Page 5: Linux System Administration - ux.brookdale.cc.nj.usux.brookdale.cc.nj.us/fac/engtech/andy/netw110/powerpoint/week11... · Backup Linux System Administration 3 Backup Linux System

Backup Linux System Administration

5

Backup Linux System Administration 9

Comparison of Backup Media

Backup Linux System Administration 10

Types of Backup Devices and Media• Tapes

– Tapes remain the most common archiving media– Earlier, 9-mm tapes were the most common tape media, but 4- and 8-millimeter

Digital Audio Tape (DAT) cartridges, about the size of an audiocassette, are now standard

– tape carts can hold from 20GB to 400GB • CD-ROMs

– Re-writable CD-ROMs have become popular– Highly secure or frequently hacked sites use read-only CD ROMS to store log

files – A CD jukebox contains multiple read-write drives and disks, which can then

store up to five stacks of 100 CDs– can back up multiple machines across a network

• DVD-ROMs– Similar to CD’s except each disk stores much more data– some DVD Jukebox systems can hold up to 200 disks, and can write either

CDs or DVDs• Other Archiving Media

– SyQuest drives, Iomega ZIP, and JAZ drives can also be used– Optical disks are similar to CDs, but they store from 100 MB to 1 GB per disk– Firewire and USB or removable hard drives are also a possibility.

Page 6: Linux System Administration - ux.brookdale.cc.nj.usux.brookdale.cc.nj.us/fac/engtech/andy/netw110/powerpoint/week11... · Backup Linux System Administration 3 Backup Linux System

Backup Linux System Administration

6

Backup Linux System Administration 11

dump and restore• Dump

– ideal for archiving entire file systems– originally developed for BSD, but is now been ported to all major

versions of UNIX– It is ideal for incremental backups because we can set it to use and

modify the /etc/dumpdates file, which lists the date and level of the latest backup

• dump uses the syntax: dump option... argument... filesystem-to-backup

• restore– allows us to retrieve the files we backed up using dump– Using restore, we can retrieve a single file or entire filesystems– Restore uses the syntax : restore options arguments file/directory

Backup Linux System Administration 12

Common dump OptionsOption/Meaning /Type s size of tape in feet

Depends upon tape length. The 8-mm default is 2400. 5400 if combined with the c option.

C use a tape cartridgeDepends on the size of the tapeoften used with s

d specifies tape densityRecent versions of dump can autodetect tape lengths and densityDepends on density. For 8-mm, 42500, or 1000 when used with the c option.

0-9 specifies the dump levelThe 0 option creates a full backup, while a 9 creates an incremental backupdump uses a zero-based count, which means that it begins counting at 0, not at 1If we do not specify a level, dump defaults to 9

u Updates /etc/dumpdates

Page 7: Linux System Administration - ux.brookdale.cc.nj.usux.brookdale.cc.nj.us/fac/engtech/andy/netw110/powerpoint/week11... · Backup Linux System Administration 3 Backup Linux System

Backup Linux System Administration

7

Backup Linux System Administration 13

Common dump OptionsOption/Meaning /Type f Name of device to write to supply a filenamed specifies tape density

Recent versions of dump can autodetect tape lengths and densityDepends on density. For 8-mm, 42500, or 1000 when used with the c option.

0-9 specifies the dump levelThe 0 option creates a full backup, while a 9 creates an incremental backupdump uses a zero-based count, which means that it begins counting at 0, not at 1If we do not specify a level, dump defaults to 9

u Updates /etc/dumpdatesn Send a message when finished

Backup Linux System Administration 14

Common restore Options-I Launches restore in interactive mode -f Specifies the device to use

If not specified, the default setting applies -r Restores the entire archive-x Restores only specified files-R Reads from a particular tape in a multivolume sequence-s Selects the specific backup tape (for use on jukeboxes) used

with R option-t Lists the contents of the archive tape-v Verbose method

Page 8: Linux System Administration - ux.brookdale.cc.nj.usux.brookdale.cc.nj.us/fac/engtech/andy/netw110/powerpoint/week11... · Backup Linux System Administration 3 Backup Linux System

Backup Linux System Administration

8

Backup Linux System Administration 15

Archiving the filesystem• When we dump the filesystem, we must specify

– the dump level• specify epochal, differential, or incremental backup

– the device where we wish to put the archive– the file system to back up

• The table shows the special file name corresponding to a tape drive for various Linux/UNIX systems

• System File name • AIX /dev/rfd0 • IRIX /dev/tape • HP-UX /dev/rmt/0 • Linux /dev/tape • Solaris /dev/rmt0 • BSD ../devices/pseudo/dump@0:dump

Backup Linux System Administration 16

Red Hat dump Example• dump 0uf /dev/rft0 /dev/hda3

– 1 5 3 4 21. Specifies the entire filesystem (level 0) 2. on /dev/hda33. should be backed up to mag tape (f option combined with

destination device) 4. at /dev/rft05. and that the dumpdate (u option) should be written to

/etc/dumpdates

Page 9: Linux System Administration - ux.brookdale.cc.nj.usux.brookdale.cc.nj.us/fac/engtech/andy/netw110/powerpoint/week11... · Backup Linux System Administration 3 Backup Linux System

Backup Linux System Administration

9

Backup Linux System Administration 17

Restoring a Filesystem• To restore a lost or damaged file system, you must first create

the partition and directory• Assume we want to recreate the /home directory on hdb1mkfs /dev/hdb1mount /dev/hdb1/homecd /homerestore rf /dev/rft0

• The r option specifies that the entire archive on rft0 should berestored to the current directory

Backup Linux System Administration 18

Backups with cpio• cpio was the original archiving utility• It does not support backing up across a network, but is very useful when

archiving entire file systems• cpio Flags Options–i extracts all files matching one or more of the given pattern arguments from

the archive. –o writes a new archive to the standard output, using the list of files read from

the standard input–b causes 16-bit words to be swapped within each long word and bytes to be

swapped within each 16-bit word of each extracted file. –d forces the creation of necessary intermediate directories if they do not

already exist. –v provides more verbose information than usual. cpio prints the names of

files as it extracts them from or adds them to archives.

Page 10: Linux System Administration - ux.brookdale.cc.nj.usux.brookdale.cc.nj.us/fac/engtech/andy/netw110/powerpoint/week11... · Backup Linux System Administration 3 Backup Linux System

Backup Linux System Administration

10

Backup Linux System Administration 19

Backups with tar• tar is a versatile and popular tape archive command• It may be used to produce archived backups on floppies or

tapes, restores backups, and can be used by non-root users with read and write permissions

• The tar syntax is simpler that cpio, but it does not copy special files or empty directories

• Restoring individual files is much easier than with cpio– you can start restoring from the volume that contains your wanted file

• We can define the name and characteristics of your default backup device in a file called /etc/default/tar

• This file can hold several such devices, which may be selected via the command line

Backup Linux System Administration 20

Backup Options with tarassign /dev/tapetar cvfk /dev/tape 1440 chap*

The example here lists the c, v, f, k options• c - creates a new archive file and starts writing at the

beginning • v verbose option causes tar to display filenames as they are

archived• f takes the /dev/tape argument as the target archive name

– Without this option, tar takes the default from a device name stored in /etc/default/tar

– also stores defaults such as blocking factor and volume size tar can also read and write from standard input and output which is useful for piping

Page 11: Linux System Administration - ux.brookdale.cc.nj.usux.brookdale.cc.nj.us/fac/engtech/andy/netw110/powerpoint/week11... · Backup Linux System Administration 3 Backup Linux System

Backup Linux System Administration

11

Backup Linux System Administration 21

tar Option Syntax• The first option letter must be either r, x, t, u, or c with no

hyphens• This first letter can be followed by one or more function

modifiers with no intervening spaces or hyphensc vf (no hyphen before the c, vf are function modifiers

• Function modifiers need their arguments listed after the group of option letters in the correct sequence

• In the following example, the option letter c is followed by two modifiers f and kf takes the argument /dev/tapek takes the argument 1440tar cvfk /dev/tape 1440 chap*

Backup Linux System Administration 22

AMANDA• AMANDA - Advanced Maryland Automatic Network Disk

Archiver - from the University of Maryland is a popular backup and restore solution

• The AMANDA server manages a pool of backup media and rotates usage through the pool

• This ensures that all backups are retained for the administratorspecified retention period

• All media is preformatted with data that allows AMANDA to detect whether or not the proper media is available

• AMANDA can be interfaced with robotic media changing units, making it possible to completely automate backups

• See http://www.backupcentral.com/amanda.html