34
1 CSC2405: System Administration Week 5 -- Backup what to do? where to? which way? Tools?

1 CSC2405: System Administration Week 5 -- Backup what to do? where to? which way? Tools?

Embed Size (px)

Citation preview

Page 1: 1 CSC2405: System Administration Week 5 -- Backup what to do? where to? which way? Tools?

1

CSC2405: System Administration

Week 5 -- Backupwhat to do?where to?

which way?Tools?

Page 2: 1 CSC2405: System Administration Week 5 -- Backup what to do? where to? which way? Tools?

Week 5: backup 2

Invaluable information

Information stored on the computer always more valuable than the computer itself. data from an experiment which you can not

repeat due to the files accidentally deleted nature disaster, fire, flood

Protecting this information is one of the system administrator’s most important tasks tedious not so creative

Page 3: 1 CSC2405: System Administration Week 5 -- Backup what to do? where to? which way? Tools?

Week 5: backup 3

Backup Policy

Backup is the best way to protect the valuable data. protection against data lose recovery from filesystem damage

A backup policy is a written statement which contains What to backup? Backup strategies Backup devices and media Backup tools

Page 4: 1 CSC2405: System Administration Week 5 -- Backup what to do? where to? which way? Tools?

Week 5: backup 4

Backup policy: what do backup? Installed system files

executables in /usr, /usr/bin, /lib /usr/lib, etc They never changes or change slowly. Frequent

backup is not really necessary. Local system files

resident in /usr/local, extra packages after the basic install

System configuration files /etc, /usr/local, /usr/local/etc,

Service files /var, services such as Web, Mail, News, DNS, NIS,

LDAP, database servers User files

/home, personal files of users on the system

Page 5: 1 CSC2405: System Administration Week 5 -- Backup what to do? where to? which way? Tools?

Week 5: backup 5

Backup strategies

Backup sometimes is very time-consuming. Full backup and incremental backup need to be used accordingly.

Fully backup is to copy all the files on the system onto a tape or other backup media.

An incremental backup contains only those files that have changed since some previous backup. Incremental backups are used when full backups

are large and only a small amount of data changes within a given period of time.

Page 6: 1 CSC2405: System Administration Week 5 -- Backup what to do? where to? which way? Tools?

Week 5: backup 6

Incremental backup level An incremental backup level is just a numeric

value that is arbitrarily assigned by the system administrator. The values for these levels range from 0 to 9, with

0 always being a full backup. Every level-n incremental backup backs up all files

changed since the previous backup at a lower level.

A differential backup is a type of incremental backup which only backs up changed files since the last differential backup. Some backup software interpret repeated level 9

backup as `different’ backups.

Page 7: 1 CSC2405: System Administration Week 5 -- Backup what to do? where to? which way? Tools?

Week 5: backup 7

Design backup strategies

Although site specific, a few basic decisions How often must I do a full backup? How often must I do an incremental backup? How much can I spend on backup media? How far in the past must I store backups? Do I need to store backup only for a full rebuild?

or Do I need to recover accidentally deleted files? How confident I am that my backup media will

not fail?

Page 8: 1 CSC2405: System Administration Week 5 -- Backup what to do? where to? which way? Tools?

Week 5: backup 8

Backup examples

A full backup will be carried out every week or every month around the calendar

Sun Mon Tues Wed Thur Fri Sat

0 0 0 0 0 0 0

A more practical backup schedule

Sun Mon Tues Wed Thur Fri Sat

0 2 2 2 2 2 4

Page 9: 1 CSC2405: System Administration Week 5 -- Backup what to do? where to? which way? Tools?

Week 5: backup 9

A more realistic backup schedule

A backup schedule that uses a new level everyday.

The advantage of this schedule less time and less media

Disadvantage changed files are backed up once need six volume to restore the system on

Friday.

Sun Mon Tues Wed Thur Fri Sat

0 1 2 3 4 5 6

Page 10: 1 CSC2405: System Administration Week 5 -- Backup what to do? where to? which way? Tools?

Week 5: backup 10

Storing backups

Storing backups needs to be on removable media. There is not much point in storing backups on a

second disk if the controller fails. Storing backups on a separate computer is not a

very effective insurance against natural disaster if the backup computer is in the same room.

Companies concerned with the preservation of their backup data will normally store them with a third party that provides magnetically shielded, temperature controlled, humidity controlled storage facilities.

Page 11: 1 CSC2405: System Administration Week 5 -- Backup what to do? where to? which way? Tools?

Week 5: backup 11

Backup devices and media

Backup devices and features Floppies: small capacity, slow, better for moving

data rather than storing data Super Floppies – Iomega’s Zip drive (250MB),

larger capacity, faster, but cost more. Better for moving data, a bit wasteful if storing data.

CD-R and CD-RW – 700MB, cheap, last long, good for incremental backup. It is time consuming, difficult and also costly for full backup.

DVD – 2GB, a bit too costly Removable hard disks – High capacity, good

choice for backups. Also faster transferring. Costly drive and costly media.

Page 12: 1 CSC2405: System Administration Week 5 -- Backup what to do? where to? which way? Tools?

Week 5: backup 12

Tapes and hard drives

Tapes – preferred backup media. largest capacity long lifetime Many formats and tape drives

Exabyte tape drives takes the standard 8mm videotapes. A standard tape can hold 7GB.

DAT: Digital Audio Tape drives are also helical scan devices that use 4mm cartridges. Currently DAT cartridges can hold upto 20GB and have a transfer of 2.5MB/s.

DLT: Digital Liner Tape drives are reliable and affordable and the tape hold upto 40GB, with 6MB/s transfer speed.

Hard drive – viable alternative backup media Not on the same machine

Page 13: 1 CSC2405: System Administration Week 5 -- Backup what to do? where to? which way? Tools?

Week 5: backup 13

Comparison of backup media

Medium Capacity Speed Relative cost

Floppy diskZip 250CD-RJazExabyteDATDLT

2.8MB250MB700MB

2GB7GB

20GB40GB

<100KB/s900KB/s2.4MB/s7.4MB/s

1MB/s2.5MB/s

6MB/s

140

2100

40160200

Page 14: 1 CSC2405: System Administration Week 5 -- Backup what to do? where to? which way? Tools?

Week 5: backup 14

Who does Backup Manual backup used to be the mainstream.

Robots were used in some lab. at command is used to do something once for ever.

Backups are periodic process. Periodic execution is normally handled by the cron daemon.

cron starts when the system boots and remaining as long as the system is up. it reads one or more configuration files that

contains command lines to execute and the time at which they are to be executed.

Page 15: 1 CSC2405: System Administration Week 5 -- Backup what to do? where to? which way? Tools?

Week 5: backup 15

cron and crontab A cron configuration file is called a “crontab” or “cron

table” file. stored in /var/spool/cron directory, /etc/cron.d directory,

/etc/crontab file A user’s crontab file is stored in the directory

/var/spool/cron. A user has at most one crontab file crontab files are named with the login names of the user

they belong to. When cron starts, it reads all of its config files, stores

them in memory, and then goes to sleep. Once a minute, cron wakes up, checks the modification

times on all the crontab files, reloads any new or changed files, and then executes any tasks scheduled for that minute before returning to sleep.

Page 16: 1 CSC2405: System Administration Week 5 -- Backup what to do? where to? which way? Tools?

Week 5: backup 16

crontab files All crontab files share a similar

format. Blank lines are ignored all lines who’s first non-blank character is

# syntaxminute hour monthday month weekday [username] command

username field is found only in the /etc/crontab file and the files found in /etc/cron.d directory

Page 17: 1 CSC2405: System Administration Week 5 -- Backup what to do? where to? which way? Tools?

Week 5: backup 17

Fields in crontab fileField Range Description

MinuteHourMonthdayMonthweekday

0-590-231-311-120-6

Minute of the hourHour of the dayDay of the monthMonth of the yearDay of the week

A star, which matches all values for that field A single integer which matches exactly A range of values, two integers separated by a bash A comma-separated list

Page 18: 1 CSC2405: System Administration Week 5 -- Backup what to do? where to? which way? Tools?

Week 5: backup 18

Examples

The following are valid time specifications for cron 45 10 * * 1-510:45Am, Monday to Friday 0,30 * * * 5 Every half hour on Friday * 0-21/3 1 * * Every third hour on the first

day of the month 17 2 * 25 * 1 2:17AM every 25th of the

month and every Monday

Page 19: 1 CSC2405: System Administration Week 5 -- Backup what to do? where to? which way? Tools?

Week 5: backup 19

crontab command As all crontab files are owned by the

superuser normal users use a setuid program to edit their

own crontab file in the directory /var/spool/cron. crontab allows the user to create or edit their

own crontab file. The option –u to crontab allows “root” to view or

edit another user’s crontab file. all users can create crontab files.

Two conf files allow the sysadmin override this policy: /etc/cron.allow and /etc/cron.denu

Page 20: 1 CSC2405: System Administration Week 5 -- Backup what to do? where to? which way? Tools?

Week 5: backup 20

An important command to backup - find

The find program searches the specified parts of the filesystem for files that match a given criterion.

Backup is to copy all files/filesystems which matches some criterion onto portable media.

The form of commandfind [path…] [criterion]where path… specifies a list of files to be tested

against the criterion

Page 21: 1 CSC2405: System Administration Week 5 -- Backup what to do? where to? which way? Tools?

Week 5: backup 21

Backup tools

Linux comes with a number of basic backup and restore utilities

dd: very low level command copying bits of information

cpio: high-level, packing data on your backup medium, correcting errors

tar: high-level, packing data and compressing data

dump/restore: incremental backup

Page 22: 1 CSC2405: System Administration Week 5 -- Backup what to do? where to? which way? Tools?

Week 5: backup 22

dd command It does not have knowledge of the

structure of the data it is coping. dd can copy a single file, a part of file, a

raw partition, or a part of a raw partition dd can copy data from stdin to stdout

while modifying it en route syntax:

dd if=device of=device bs=blocksize. The data is written directly onto the

device, not via a filesystem.

Page 23: 1 CSC2405: System Administration Week 5 -- Backup what to do? where to? which way? Tools?

Week 5: backup 23

dd if=device of=device bs=blocksize if: specify the input file from which dd is

going to copy the data. It can be disk parition, a full disk, a CDROM or a tape device. If not specified, dd reads from stdin.

of: output file to where dd is going to write the data. any devices like if. If not specified, then dd writes to stdout.

bs: specifies the block size, ot the amount of data is to be transferred in one I/O operation.

Page 24: 1 CSC2405: System Administration Week 5 -- Backup what to do? where to? which way? Tools?

Week 5: backup 24

dd example

Copy all the bytes on a floppy disk to a file on system hard disk called diskette.img dd if=/dev/fd0 of=diskette.img

Page 25: 1 CSC2405: System Administration Week 5 -- Backup what to do? where to? which way? Tools?

Week 5: backup 25

cpio archiving program cpio performs three primary functions

copying files to an archive extracting files from an archive passing files to another directory tree.

When creating an archive, cpio takes the list of files to be processed from the standard input, then sends the archive to the standard output (or a file or device specified by a cpio option). Usually find is used to provide this list to the

standard input of cpio.

Page 26: 1 CSC2405: System Administration Week 5 -- Backup what to do? where to? which way? Tools?

Week 5: backup 26

cpio syntax and example

syntax copying: cpio –ov > achive extracting: cpio –iv < archive

examples cpio –ov > /dev/st0 < /tmp/list_of_filescopying all files whose name in

/tmp/list_of_files file to SCSI tape find . –depth print | cpio –ov > dir.cpiofind a list of files and then copy them to a file

Page 27: 1 CSC2405: System Administration Week 5 -- Backup what to do? where to? which way? Tools?

Week 5: backup 27

cpio syntax and example

examples cpio –idv < dir.cpioextract the files from the dir.cpio archive to

the current directory. The –d option tells cpio to create directories as they are needed.

cpio –ivt < /dev/st0go back and check the backup by reading the

tape and checking the table of contents.

Page 28: 1 CSC2405: System Administration Week 5 -- Backup what to do? where to? which way? Tools?

Week 5: backup 28

tar - tape archiving tar was used to store file conveniently

on magnetic tape. tar archives are extremely portable

between Unix platforms and are readable on other operating systems.

syntaxcreate: tar –cvf device patternextract: tar –xvf device [filename…]

you may restore some files from the archive by specifying their filename .

Page 29: 1 CSC2405: System Administration Week 5 -- Backup what to do? where to? which way? Tools?

Week 5: backup 29

tar examples If the floppy is really too small for that amount of data

but you still want to use diskettestar –cvMf /dev/fd0 /mydata

To compress data tar –czvf /dev/st0 /mydata

-p option may well be the most important tar option of them all. This tells tar to preserve permissions and ownership

information in both backups and restore. The latest versions of tar will allow the user to specify

a file containing a list of file to archieve.find /home –user $USER –depth > file.listtar –zcvf ${SER}.tag –T file.list

Page 30: 1 CSC2405: System Administration Week 5 -- Backup what to do? where to? which way? Tools?

Week 5: backup 30

a duo of backup dump/restore are relatively sophisticated backup

commands. at most sites, dump/restore are the underlying

commands used by automated backup software dump builds a list of files that have been modified

since a previous dump, then packs those files into a single large file to archive on an external device. backups can span multiple tapes files of any type (even devices) can be backed up and

restored Permissions, ownership and modification times are

preserved. Backups are performed incrementally

Page 31: 1 CSC2405: System Administration Week 5 -- Backup what to do? where to? which way? Tools?

Week 5: backup 31

dump/restore syntax dump –level –ffilename filesystem restore –rf device examples

dump -0uf - /dev/hdb1 | cat > /dev/st0 0: full backup u: to update /etc/dumpdates after it has

successfully complete -: redirect to standard out, then use pipe

to redirect that to a tape drive.

Page 32: 1 CSC2405: System Administration Week 5 -- Backup what to do? where to? which way? Tools?

Week 5: backup 32

dump/restore syntax

examples dump -1uf - /dev/hdb1 | cat > /dev/st0 level 1 incremental backup restore –rf /dev/st0

must use mke2fs to recreate the file system cd to that directory

Page 33: 1 CSC2405: System Administration Week 5 -- Backup what to do? where to? which way? Tools?

Week 5: backup 33

Identity backups To backup every essential files such as its

configuration file is called identity backup. it will collect all the files that make you put-

together server unique among all other put-together servers.

You can reinstall Linux from the CD-ROM in minutes, but getting everything just right might take a little longer than that and users want their e-mail and Internet access yesterday.

Page 34: 1 CSC2405: System Administration Week 5 -- Backup what to do? where to? which way? Tools?

Week 5: backup 34

identity backup script On this server of yours, you may be running

diald, fetchmail, IP asquerading, and e-mail. using the –p flag on mkdir to save create

entire subdirectory in one pass you could tar the whole thing to a floppy

and save yourself a step. Alternatively, you can ftp the file to another server, a Window PC or to your own server.