Backup Restore Objectives to understand Unix backup strategies
Backup & Restore • Objectives – to understand Unix backup strategies • Contents – why have backups – backup terminology – backup media – backup utilities – issues about backup security • Practical – to perform backups • Summary
Why Backup? • Backups help recover data in the event of system failure • Allow users to recover accidentally (or deliberately) corrupt or deleted files • Used to retain data while systems are upgraded • Backups are also be used for transferring data between nonnetworked machines BACKUPS ARE USELESS IF THEY CANNOT BE RESTORED
When to Backup • Use cron to schedule backup scripts to run overnight • Backup changing data every day – possibly use a full backup on one day – and incremental backups on the rest – make sure you change tapes every day – don't backup to the same tape all the time # more backup. full DAY=`date +%a` cd / touch /var/adm/backup. full find etc home var -print | cpio -ocv. BO /dev/st 0 2>/var/adm/log. $DAY # more backup. inc DAY=`date +%a` cd / find etc home var -newer /var/adm/backup. full -print | cpio -ocv. BO /dev/nst 0 2> /var/adm/log. $DAY
Where to Store Backups • Store backups in a lockable fireproof safe – if you don't have one buy one, they're not expensive • Unix backups are insecure – there are no access controls – anyone with physical access to the media can restore the data • Take backups and archives off-site – backups are no good if they are burnt/flooded with the computer systems – however, remember that data is confidential • Don't keep backups immediately next to the machine – at the very least put the backups in a different building or room
What to Backup? • Backup those files which change on a daily basis: /etc Unix configuration file /var Unix files which vary on a day to day basis /home user files – only backup the entire system when needed • Backup the entire system on a regular basis – especially before updating the system – before preventative maintenance or moving the hardware • Be careful with database systems – databases usually involve several files which must be consistent – stop database systems before backing up their files – some databases have a backup mode used when the system cannot be taken down for backups – databases using raw disks for storage will provide their own backup
Backup Media • Traditional backup media is magnetic tape – reel-to-reel (½" or 9 -track) – cartridge tape (¼" or SCSI tape) – video-8 (Exabyte) – DAT (Digital Audio Tape) – DLT (Digital Linear Tape) • Other media include – removable disk packs (Bernoulli) – WORM disk (Write Once Read Many optical disks) – recordable CD (CD-R/DVD) – rewriteable optical disk (MO, phase change)
Magnetic Tape • Magnetic tapes susceptible to magnetic fields – power cables, motors, magnets, etc. • Cartridge media degrades with time and use – 2 year life span and should be read every 6 -12 months – replace tapes after 10 writes (20 at most!) • DAT, DLT and Exabyte will last longer – but still have a limited life • Needs careful storage – temperate and humidity controlled – sunlight (don't leave on a windowsill) Don't compromise your backups by using cheap or worn media
Optical Disks • Optical disks have advantages over magnetic tapes – digital recording – reliable & robust media – compact media – can be treated as disks (no need to use backup utilities) • Also have disadvantages – smaller capacity – more expensive media/drives (less true as technology advances) • WORM or CD-R is the only choice for long term archives – data that must be kept for more than one year
Unix Backup Terminology • Archive – full backup taken off-line (deleted from the system) • Image backup – complete copy of a disk or partition • Full backup – complete directory backup by files • Incremental backup – files changed since last full or incremental backup • Dump levels (0 -9) – files changed since last backup at same or lower dump level – level 0 dump is a full backup
Backup Utilities • File oriented utilities cpio tar - copy to I/O - tape archive and restore • Filesystem utilities dump - backup linux filesystems WARNING! OBSOLETE! restore - restore linux dump WARNING! OBSOLETE! dumprx - dump Veritas filesystems restorerx - restore Veritas dump • Device level dd - direct device access(image backups) • Proprietary utilities – yast backup, Su. SE backup – some manufacturers provide their own utilities (AIX: backup & restore) – if you use these you are tied to that manufacturer • Third party Applications
Tape Archive and Restore • Use tar for quick and simple backups – not flexible enough for sophisticated backup strategies • Files are written to the archive in tar format – directory pathname and inode information – user, group and permission information – creation and modification times # # # cd /home/radar tar cvf /dev/st 0. tar tvf /dev/st 0 cd /tmp tar xvf /dev/st 0 SCSI Tape device in Linux are usally called: /dev/nst[0 -31] rewind /dev/st[0 -31] no rewind Dencity modes: -, a, l, m
Copy to I/O • Use cpio for system backups – supports flexible and sophisticated backup strategies • Files are written to the archive in cpio format – directory pathname and inode information – user, group and permission information, creation and modification times list of files from stdin cpio -o writes archive to stdout archive read from stdin cpio -it table of contents to stdout archive read from stdin cpio -i files restored according to archived pathname
Options to cpio • General options -vverbose mode -Buse large blocks -C n use blocks of n bytes -cuse ASCII headers (always use this option) · Specify I/O devices with -O file -I file for better handling of multi-volume media when archiving for better handling of multi-volume media when restoring · Input (restore) options -tlist table of contents rather than restore files -dcreate directories if needed -uunconditionally restore files -mretain file modification times
Exercise - Using cpio • Explain the purpose of the following commands? # find. -print | cpio -ovc. B >/dev/rmt/0 m # cpio -itvc. B </dev/rmt/0 m # cd /tmp # cpio -ivcdum. B </dev/rmt/0 m # cd / # find etc home var -print | cpio -ovc. B -O /dev/rmt/0 m # cd /tmp # cpio -ivcdm. B -I /dev/rmt/0 m 'etc/init. d etc/rc*. d'
Summary • Unix provides basic utilities for performing backups tar, cpio dump & restore dumprx & restorerx dd • Unix backups are written to the media with their file attributes and pathnames • Unix backups are insecure, there are no access control restrictions Keep all backups in a locked temperature and humidity controlled environment • Backups are vital to system integrity - keep offsite backups if possible
- Slides: 15