Linux System Administration
System Backup Strategies
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
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 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
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 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
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
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
Backup Linux System Administration 9
Comparison of Backup Media
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
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
Common dump Options
Option/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 cartridge
Depends on the size of the tape often used with s
d specifies tape density
Recent versions of dump can autodetect tape lengths and density Depends on density. For 8-mm, 42500, or 1000 when used with the c option.
0-9 specifies the dump level
The 0 option creates a full backup, while a 9 creates an incremental backup dump uses a zero-based count, which means that it begins counting at 0, not at 1
Backup Linux System Administration 13
Common dump Options
Option/Meaning /Type
f Name of device to write to supply a filename d specifies tape density
Recent versions of dump can autodetect tape lengths and density Depends on density. For 8-mm, 42500, or 1000 when used with the c option.
0-9specifies the dump level
The 0 option creates a full backup, while a 9 creates an incremental backup dump uses a zero-based count, which means that it begins counting at 0, not at 1
If we do not specify a level, dump defaults to 9 u Updates /etc/dumpdates
n Send a message when finished
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
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
Red Hat dump Example
•
dump 0uf /dev/rft0 /dev/hda3
–
1 5 3 4 2
1. Specifies the entire filesystem (level 0)
2. on /dev/hda3
3. should be backed up to mag tape (f option combined with
destination device)
4. at /dev/rft0
5. and that the dumpdate (u option) should be written to
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 hdb1
mkfs /dev/hdb1
mount /dev/hdb1/home
cd /home
restore rf /dev/rft0
• The r option specifies that the entire archive on rft0 should be
restored to the current directory
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.
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 Options with tar
assign /dev/tape
tar 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
Backup Linux System Administration 21