Objectives After completing this unit, students should be able to: Identify issues which have to be considered when deciding which backup ompolicies to implement: r f l ria Media to be eused t a Frequency IX M of the backup A Type T ofSbackup
B
List the different backup methods supported through SMIT and on the command line Create a customized installable system image backup Execute other useful commands to manipulate the backed up data on the media
Why Backup? Data is very important: Expensive to recreate Can it be recreated?
m o r f l Disaster recovery: ria e t a Hardware Mfailure X I A due to installation/repair Damage BTS deletion Accidental Transfer of data between systems Reorganizing file systems Defragmentation to improve performance System image for installation Checkpoint (before/after upgrade) Long term archive
Why Restore? Recover files "I've just deleted file abc by mistake"
m Compare versions fof ofiles r l "I'm sure itatwas eria fixed in 6.0.22" M
AIXsystem after disaster Recover S that the plumber has been in ..." "well BTnow Restore archived data "you remember that project we did in 1997 ..." Shrink a file system
Types of Backup Three types of backup: System Records image backup fromof the operating system
eria t a M
l
Full AIX all user data and configuration files Preserves
TS B Incremental
Records changes since previous backups Must be used carefully Very quick
rootvg
Backup Strategy Backup all data that changes! System backup
at M AIX BTS
e
ro f l a ri
m Full backup
Incremental backup
Incremental backup
Backup Devices - Diskette /dev/fd0 /dev/fd1
Built in 3 1/2" diskette drive Second diskette drive
at M AIX BTS
e
ro f l a ri
m Drive
3 1/2"(1.44)
3 1/2"(2.88)
/dev/fdxl
720 KB
/dev/fdxh
1.44 MB
720 KB 2.88 MB
/dev/fdx.9
720 KB
720 KB
/dev/fdx.18
1.44 MB
1.44 MB
/dev/fdx.36
-
2.88 MB
Backup Devices - Tape 4 mm DAT
1/2 - inch
8 mm
DLT
om r f Low l ria
Capacity
Retension on Open
Rewind on Close
no
no
yes
/dev/rmtx.1
no
no
no
/dev/rmtx.2
no
yes
yes
/dev/rmtx.3
no
yes
no
/dev/rmtx.4
yes
no
yes
/dev/rmtx.5
yes
no
no
/dev/rmtx.6
yes
yes
yes
/dev/rmtx.7
yes
yes
no
e Mat
IX A /dev/rmtx S BT
Backup Device - Read/Write Optical Drive
Use with CD-ROM file system for
er t a M
AIX BTS
ia
m l fro read only operations
Use with journal file systems for read/write operation
Backup Menus System Storage Management (Physical and Logical) Logical Volume Manager File Systems Files and Directories System Backup Manager
ro f l a ri
ate M AIX Back up a File System Restore T B aSFile System File Systems
List Contents of a Backup
m
Files and Directories Back up a File or Directory Restore a File or Directory List Contents of a Backup
Logical Volume Manager Volume Groups Logical Volumes Physical Volumes Paging Space
System Backup Manager Back up the System List Files in a System Image Restore Files in a System Image
Volume Groups Back up a Volume Group Remake a Volume Group List Files in a Volume Group Backup Restore Files in a Volume Group Backup
rootvg Backup Process - mksysb Backs up rootvg only Unmounted file systems are not backed up
m
Bootable tape isiacreated l fro in backup format
er t a M
Provides IX facilities for a non-interactive installation
A TS SavesBsystem-created paging space definitions Saves logical volume policies
There should be minimal user and application activity
/image.data File for rootvg image data: IMAGE_TYPE=bff DATE_TIME=Wed May 9 15:07:28 PDT 2001 UNAME_INFO=AIX sys2 1 5 000930134C00 PRODUCT_TAPE=no USERVG_LIST= OSLEVEL=4.3.1.0 logical_volume_policy: SHRINK=no EXACT_FIT=no ils_data: LANG=C #Command used for vg_data, /usr/sbin/lsvg lsvg_data: VGNAME=rootvg PPSIZE=4 VARYON=yes VG_SOURCE_DISK_LIST=hdisk0 hdisk1 #Command used for source_disk_data: /usr/sbin/bootinfo source_disk_data: (stanza is repeated for each disk in rootvg) LOCATION=(disk location) SIZE_MB=(size of disk in megabytes) HDISKNAME=(disk name) #Command used for lv_data; /usr/sbin/lslv lv_data: (stanza for each logical volume in rootvg) . . fs_data: (stanza for each MOUNTED filesystem in rootvg)
at M AIX BTS
e
ro f l a ri
m
/bosinst.data File for rootvg control_flow: CONSOLE = INSTALL_METHOD = overwrite PROMPT = yes EXISTING_SYSTEM_OVERWRITE = no INSTALL_X_IF_ADAPTER = yes RUN_STARTUP = yes RM_INST_ROOTS = no ERROR_EXIT = CUSTOMIZATION_FILE = TCB = no INSTALL_TYPE = BUNDLES = RECOVER_DEVICES = yes BOSINST_DEBUG = no ACCEPT_LICENSES = INSTALL_64BIT_KERNEL = no INSTALL_CONFIGURATION = Default DESKTOP = CDE
at M AIX BTS
e
ro f l a ri
m
target_disk_data: LOCATION = SIZE_MB = HDISKNAME = locale: BOSINST_LANG = CULTURAL_CONVENTION = MESSAGES = KEYBOARD =
rootvg Image Backup # smit mksysb Back Up the System Type or select values in entry fields. Press Enter AFTER making all desired changes.
e Mat
ro f l a ri
m
[Entry Fields]
WARNING: Execution of the mksysb command will result in the loss of all material previously stored on the selected output medium. This command backs up only rootvg volume group.
AIX BTS
* Backup DEVICE or FILE Create MAP files? EXCLUDE files? List files as they are backed up? Generate new /image.data file? EXPAND /tmp if needed? Disable software packing of backup? Number of BLOCKS to write in a single output (Leave blank to use a system default)
[] no no no yes no no []
F1=Help F5=Reset F9=Shell
F4=List F8=Image
F2=Refresh F6=Command F10=Exit
F3=Cancel F7=Edit Enter=Do
+/ + + + + + + #
mksysb Image Blocksize = 512
Blocksize = 512
ro f l a ri
m
BOS Boot amkinsttape te M image image AIX
BTS
Kernel Device Drivers
./image.data ./bosinst.data
Blocksize = 512
Tape Drive Blocksize
dummy .toc
rootvg data
Dummy TOC
backup by name
Non-rootvg Backup # smit savevg Back Up a Volume Group to Tape/File Type or select values in entry fields. Press Enter AFTER making all desired changes.
e Mat
ro f l a ri
m
WARNING: Execution of the savevg command will result in the loss of all material previously stored on the selected output medium.
[Entry Fields]
AIX BTS
* Backup DEVICE or FILE * VOLUME GROUP to back up List files as they are backed up? Generate new vg.data file? Create MAP files? EXCLUDE files? EXPAND /tmp if needed? Disable software packing of backup? Number of BLOCKS to write in a single output (Leave blank to use a system default) F1=Help F5=Reset F9=Shell
F2=Refresh F6=Command F10=Exit
F3=Cancel F7=Edit Enter=Do
[] [] no yes no no no no [] F4=List F8=Image
+/ + + + + + + + #
Restoring a mksysb (1 of 2) Boot the system in install/maintenance mode: Welcome to Base Operating System Installation and Maintenance 1 2 >> 3
ro f l a ri
m
Start Install Now With Default Settings Change/Show Installation Settings and Install Start Maintenance Mode for System Recovery
at M AIX BTS
e
Maintenance 1 2 3 >> 4
Access A Root Volume Group Copy a System Dump to Removable Media Access Advanced Maintenance Functions Install from a System Backup
Choose Tape Drive >> 1
Tape Drive tape/scsi/4mm/2GB
Path Name /dev/rmt0
Restoring a mksysb (2 of 2) Welcome to Base Operating System Installation and Maintenance
ro f l a ri
m
Type the number of your choice and press Enter. Choice is indicated by >>. 1 Start Install Now With Default Settings Change/Show Installation Settings and Install >> 2 3 Start Maintenance Mode for System Recovery
at M AIX BTS
e
System Backup Installation and Settings Type the number of your choice and press Enter. 1 2 3 0
Disk(s) where you want to install Use Maps Shrink Filesystems Install with the settings listed above
hdisk0 No No
Restoring a non-rootvg Volume Group # smit restvg Remake a Volume Group
ro f l a ri
m
Type or select values in entry fields. Press Enter AFTER making all desired changes.
ate M IX A * Restore DEVICE or FILE BTtheSfilesystems? SHRINK
[Entry Fields] [/dev/rmt0] no PHYSICAL VOLUME names [] (Leave blank to use the PHYSICAL VOLUMES listed in the vgname.data file in the backup image) Use existing MAP files? yes Physical partition SIZE in megabytes [] (Leave blank to have the SIZE determined based on disk size) Number of BLOCKS to read in a single input [] (Leave blank to use a system default)
F1=Help F5=Reset F9=Shell
F2=Refresh F6=Command F10=Exit
F3=Cancel F7=Edit Enter=Do
F4=List F8=Image
/+ + + + +# #
Activity: savevg
om r Activity: f l eria t a M AIX savevg BTS
backup by File Name backup -i [-q] [-p] [-v] [-f device] -q -p -v
media is ready from compressiafiles which are less than 2 GB l r e t verbose Ma - display filenames during backup
AIX BTS
Filenames are read from standard input
backup by File Name Examples Read input from a file #cat listfile /home/roy/file1 om r f l /home/roy/file2ateria M /home/roy/file3 AIX # backupT-iqvf S /dev/rmt0 < listfile
B
Use find to generate list # find /home/roy | backup -iqvf /dev/rmt0 # cd /home/roy # find . | backup -iqvf /dev/rmt0 Relative vs Full Filenames will impact Location of Files on Recovery !
backup a File or a Directory # smit backfile Backup a File or Directory
ro f l a ri
m
Type or select values in entry fields. Press Enter AFTER making all desired changes. [Entry Fields] This option will perform a backup by name. * Backup DEVICE [/dev/fd0] +/ * FILE or DIRECTORY to backup [.] Current working DIRECTORY [] / Backup LOCAL files only? yes + VERBOSE output? no + PACK files? no +
at M AIX BTS
F1=Help F5=Reset F9=Shell
e
F2=Refresh F6=Command F10=Exit
F3=Cancel F7=Edit Enter=Do
F4=List F8=Image
backup a File System by Inode Syntax: backup [-u] [-level] [-f device] filesystem
ro f l a ri
m
Levels provide ateincremental backups: M IX system back up -0 FullAFile S -1,-2, ...BTbackup changes since level -1 /etc/dumpdates contains a backup history -u updates /etc/dumpdates # backup -u -1 -f /dev/rmt0 /home
Incremental backup Example Sun
Mon
Tue
Wed
Thur
Fri
Sat 1
2
8
9
12 13 14 15 level 6 level 6 level 6 level 0
16
17
18 19 20 21 22 level 6 level 6 level 6 level 6 level 3
23
24
25 26 27 28 29 level 6 level 6 level 6 level 6 level 0
30
l teria
a4 M X I 6 Alevel TS B 10 11 3
level 6
31
from
level 6
5
level 0 level 6
6
level 6
7
level 3
Backup a File System by Inode # smit backfilesys Backup a Filesystem Type or select values in entry fields. Press Enter AFTER making all desired changes.
ro f l a ri
m
ate M IX will perform a backup by inode. [Entry Fields] Aoption This * FILESYSTEM [] +/ BTS to backup * Backup DEVICE Backup LEVEL (0 for a full backup) RECORD backup in /etc/dumpdates?
F1=Help F5=Reset F9=Shell
F2=Refresh F6=Command F10=Exit
F3=Cancel F7=Edit Enter=Do
[/dev/fd0] [0] no
F4=List F8=Image
+/ # +
restore Command List files on media (Verify the backup) restore -T [-q] [-v] [-f device]
m
ro f # restore -Tvf /dev/rmt0 l a i er t a M
IX A RestoreTindividual files. S B restore -x [-q] [-v] [-f device] [file1 file2 ..] # restore -xvf /dev/rmt0 /home/mike/manual/chap1 Restore complete file system restore -r [-q] [-v] [-f device] Restore backups in order, that is, -0 then -1 and so forth # restore -rqvf /dev/rmt0
Restore a File or a Directory # smit restfile Restore a File or Directory
m
Type or select values in entry fields. Press Enter AFTER making all desired changes.
ro f l a ri
ate M IX A * Restore DEVICE TS * TargetB DIRECTORY
FILE or DIRECTORY to restore (Leave blank to restore entire archive.) VERBOSE output? Number of BLOCKS to read in a single input operation
F1=Help F5=Reset F9=Shell
F2=Refresh F6=Command F10=Exit
[Entry Fields] [/dev/fd0] [.] []
F3=Cancel F7=Edit Enter=Do
no []
+/ / + #
F4=List F8=Image
Exercise: Using backup and restore
at M AIX BTS
om r f Exercise: l ria
e Using backup and restore
Other UNIX backup Commands tar (tape archive) Widely available Good for transfer of data between platforms m oextended r f Has no support for inode (ACLs) l ia
er t a M
IX A cpio (copy TS input to output) B Widely available
Difficulties can occur with many symbolic links Has no support for extended inode (ACLs)
dd (device to device) Makes backup copies that are an exact image Can also be used for conversions For example: can convert ASCII to EBCDIC
tar Command Generate a tar backup # tar -cvf /dev/rmt0.3 /home
ro f l a ri
m
ate M RestoreIX A a file from a tar image BTS
# tar -xvf /dev/rmt0 /home/team01/mydir
List (verify) content of a tar file # tar -tvf /dev/rmt0
cpio Command Generate a cpio backup # find /home | cpio -ov> /dev/rmt0
ro f l a ri
m
e Restore from Maat cpio image AIX S
List (verify) contents of a cpio image # cpio -itv < /dev/rmt0
dd Command Converts and copies files To copy a file to diskette # dd if=/etc/inittabl fof=/dev/rfd0 rom
er t a M
ia
X S BT if=text.ascii
AI a file from ASCII to EBCDIC To convert # dd
of=text.ebcdic conv=ebcdic
To convert data to uppercase characters # cat lcase.data | dd conv=ucase
Controlling the Tape rewind - rewinds a tape fsf - fast forwards a tape froma tape offline -iaejects l er- rewinds and ejects a tape t a rewoffl M
tctl
AIX TS B # tctl -f /dev/rmt0 rewind # tctl # tctl
-f /dev/rmt0.1 fsf 3 -f /dev/rmt0 rewoffl
restore -s # restore -s 4 -xvf /dev/rmt0.1 ./etc/inittab
Good Practices Verify your backups Check the tape device from
eria t a M
l
IXbackups KeepAold BTS
Offsite secure storage Label tape Test recovery procedures before you have to!
Optional Exercise: Using tar and cpio
Optional
er t a M
AIX BTS
ia
m l froExercise: Using tar and cpio
Checkpoint 1. What is the difference between A and B? a. find /home/fred | backup -ivf /dev/rmt0 b. cd /home/fred; find . | backup -ivf /dev/rmt0 ___________________________________________________ m o r f l ___________________________________________________ ria e t a ___________________________________________________ M
IX A 2. On a mksysb tape if you entered tctl rewind and then tctl S T B -f/dev/rmt0.1 fsf 3 which element on the tape could you look at? ___________________________________________________ ___________________________________________________
Which command could you use to restore these files? ___________________________________________________ ___________________________________________________ 3. True or false? SMIT mksysb will backup all file systems, provided they are mounted.
Unit Summary In order to perform successful backups, consideration must be given to the frequency of the backup, the media to be used and the type of backup
om r f l Backups canatbe eriainitiated on a single file, a file system or M an entire group, all of which are supported IX volume A throughTSMIT B S
By modifying the bosinst.data and the image.data files, a customized system image backup can be created There are many other UNIX backup commands which can be used, however their limitations must be fully understood. The commands include: tar, cpio and dd Other useful commands also exist to manipulate the data on the backup media such as tctl