Few Points:
a. rootvg backup can be taken thru mksysb command. Most people refer it as mksysb backup.
b. This type of backup on a tape is bootable. Hence its been widely used to restore the system incase of system crash.
c. Mksysb backup contains 4 images
i. BOS Boot Image - Kernel Device Drivers
ii. mkinsttape image - ./image.data, ./tapeblksz, ./bosinst.data and few other commands
iii. dummy .toc - Nothing but a dummy table of contents file
iv. rootvg data - This is where the actual data resides
Files used by mksysb:
/image.data :
Contains information about the image installed during the BOS installation process. This includes the sizes, names, mount points of LVs and file systems in the rootvg [Actually nothing but the rootvg structure]. It can be created using mkszfile command.
/var/adm/ras/bosinst.data:
It allows you to customize the OS installtion. Modified mostly to use the mksysb image to install new servers.
Few Commands :
To generate just /image.data :
# mkszfile
To create /image.data and generate a system backup on the tape :
# mksysb -i /dev/rmt0
To generate a system backup on the tape but to exclude /home directory and to create /image.data :
# echo /home > /etc/exclude.rootvg# mksysb -ei /dev/rmt0
To list the contents of a mksysb image :
# lsmksysb -f /backup/system1.mksysb
To restore a specific file from mskysb image :
a. Rewind the tape :
# tctl -f /dev/rmt0 rewind
b. Move the tape forward to the end of 3rd image :
# tctl -f /dev/rmt0.1 fsf 3
c. Restore the specific file:
# restore -xqvf /dev/rmt0.1 /home/user1/file1
Non-rootvg Backup :
Few Points:
a. Volume groups other than rootvg can be backup'ed using savevg command.
b. You can exclude certain files by creating /etc/exclude.vgname.
c. VG data files are kept under,
/tmp/vgdata/vg-name/vg-name.data.
Few Commands :
To backup a datavg to the tape drive :
# savevg -if /dev/rmt0 datavg
To backup a datavg to the tape drive and exclude certain files :
# savevg -ief /dev/rmt0 datavg
To restore the datavg image from the tape onto the disks specified in /tmp/vgdata/datavg/datavg.data file :
# restvg -f /dev/rmt0
File System Backup :
File systems can be backup'ed using many ways.Few commands used for this are backup, cpio, dsm [TSM Client].
To back up all the files and subdirectories in the /home directory using full path names :
# find /home -print backup -if /dev/rmt0
To back up all the files and subdirectories in the /home directory using relative path names :
# cd /home
# find . -print backup -if /dev/rmt0
I-node Base Backup:
To back up the /home file system by i-node :
# backup -0 -uf /dev/rmt0 /home
i-node based backup has the advantage of making incremental and differential backups. Here we use the numeric flags (0 to 9) to make the difference in the way it back ups. It actually updates the date/time/mode of last backup in /etc/dumpdates when you use the 'u' flag.
Here are the different numeric flags used and their meanings,
0 - Full Backup
1 - Back ups the files created/modified from the date/time of 0th backup
2 - Back ups the files created/modified from the date/time of 1th backup
3 - Back ups the files created/modified from the date/time of 2th backup
4 - Back ups the files created/modified from the date/time of 3th backup
5 - Back ups the files created/modified from the date/time of 4th backup
6 - Back ups the files created/modified from the date/time of 5th backup
7- Back ups the files created/modified from the date/time of 6th backup
8 - Back ups the files created/modified from the date/time of 7th backup
9 - Back ups the files created/modified from the date/time of 8th backup
Few Examples for i-node based backup :
Scenario 1 - Full and Incremental Backup :
If you want to have full backup of /home on sunday night and incremental backup on other nights, then follow the below procedure.
Sunday Night - Full Backup :
# backup -0 -uf /dev/rmt0 /home
Monday Night - Incremental Backup :
# backup -1 -uf /dev/rmt0 /home
Tuesday Night - Incremental Backup
# backup -2 -uf /dev/rmt0 /home
Wednesday Night - Incremental Backup :
# backup -3 -uf /dev/rmt0 /home
Thursday Night - Incremental Backup :
# backup -4 -uf /dev/rmt0 /home
Friday Night - Incremental Backup
# backup -5 -uf /dev/rmt0 /home
Saturday Night - Incremental Backup :
# backup -6 -uf /dev/rmt0 /home
Advantages of Incremental Backup:
a. It takes lesser time to restore the specific data.For example, if you lose a file that was created on thursday morning, then you need only the wednesday night tape to restore the specific file.
b. This method consumes less tapes for backup. Hence its cost effective compared to differential backup.
Disadvantages of Incremental Backup:
a. You need more number of tapes (from sunday-full to last night-incre) to restore the entire file system.
Scenario 2 - Full and Differential Backup :
If you want to have full backup of /home on sunday night and differential backup on other nights, then follow the below procedure.
Sunday Night - Full Backup :
# backup -0 -uf /dev/rmt0 /home
Monday Night - Differential Backup :
# backup -1 -uf /dev/rmt0 /home
Tuesday Night - Differential Backup :
# backup -1 -uf /dev/rmt0 /home
Wednesday Night - Differential Backup :
# backup -1 -uf /dev/rmt0 /home
Thursday Night - Differential Backup :
# backup -1 -uf /dev/rmt0 /home
Friday Night - Differential Backup :
# backup -1 -uf /dev/rmt0 /home
Saturday Night - Differential Backup :
# backup -1 -uf /dev/rmt0 /home
Advantages of Differential Backup:
a. It takes less tapes (from sunday-full and last night-incre) to restore the entire file system.Hence it is easy for the backup operator to restore the data.
Disadvantages of Differential Backup:
a. It consumes more tapes for backup. (since we are going to backup the same old files again and again for the whole week).Hence cost is more in this type of backup.
To list the contents of backup on the tape :
# restore -Tvf /dev/rmt0
To restore individual files from backup created by 'backup -i' command :
# restore -xvf /dev/rmt0 /home/user1/file1
To restore the entire file system :
# restore -rvf /dev/rmt0
Other Unix Backup Commands:
TAR:
tar is the only command (i think so) in UNIX which doesnot require a dash(-) infront of a flag.
To create a tar image in /tmp for a directory :
# tar cvf /tmp/oradata.tar /opt/oradata
To view the contents of a tar image :
# tar tvf /tmp/oradata.tar
To restore the tar image :
# tar xvf /tmp/oradata.tar
CPIO :
cpio reads and writes from stdin and stdout.
To backup the current directory to a /tmp/file.cpio file :
# find . -print cpio -ov > /tmp/file.cpio
To view the table of contents of the cpio archived tape :
# cpio -itvcC1 < /dev/rmt0
To restore data from the cpio archive file :
# cpio -idv < /tmp/file.cpio
To restore a selective file from cpio archived tape :
# cpio -imv /home/roger/.profile < /dev/rmt0
To restore selectively only the *.c and *.cpp file :
# cpio -i "*.c" "*.cpp" < /dev/rmt0
DD Command :
'dd' command copies (also converts) from an input device to an output device. This command will not span multiple tapes.
To copy a file and converting all the chars to upper case :
# dd if=/tmp/unixfile.txt of=/tmp/dosfile.txt conv=ucase
Tcopy Command :
Copies from one tape device to another.
To list the contents of a tape media :
# tcopy /dev/rmt0
To copy all the data from one tape to another tape device :
# tcopy /dev/rmt0 /dev/rmt1
tctl Command :
tctl has been widely used to control tape drives.
To rewind a tape device :
# tctl -f /dev/rm0 rewind
To fast forward to the beginning of 2nd tape mark :
# tctl -f /dev/rmt0.1 fsf
To do retension :
# tctl -f /dev/rmt0 retension
Retension is nothing but moving the tape to beginning, end and again to the beginning. You have to do this, if you encounter multiple read errors during the restoration operation.
To display the status of atape device :
# tctl -f /dev/rmt0 status
To eject a tape device :
# tctl -f /dev/rmt0 offline
TSM Client :
Few Points:
a. It requires a connection to TSM server and also a registeration in the TSM server.
b. You can take the 'backup' and 'archive' based on the TSM server configuration.
c. Archive can be taken for 90 days, 180 days, ... based on the management class.
d. Backup can have different versions. Last backup is the new and current version and oldest backup is the old version for every file that is backed up.
e. Most of the small sized companies keep 3 versions of backup, that means can have 3 backup version for each file.
To Backup a file :
# dsm backup /tmp/file1
To archive a file :
# dsm archive /tmp/file1
To list all the backed up filesystems :
# dsm query filespace
To verify the backup of a file :
# dsmc query backup /tmp/file1
To verify the inactive version of a backup of a file :
# dsmc query backup -inactive /tmp/file1
To verify the archive of a file :
# dsmc query archive /tmp/file1
To backup VIO Server :
To take the OS backup in a CD ROM :
# backupios –cd /dev/cd1 -cdformat
To take the OS backup in a DVD-RAM :
# backupios –cd /dev/cd1 -udf
To take the OS backup in a tape drive :
# backupios –tape /dev/rmt0
To verify the backup available in a tape :
# backupios –tape /dev/rmt0 -verify
To generate vio backup (tar file) in a file :
# backupios –file /opt/file1
To generate vio backup (mksysb image) in a file :
# backupios –file /opt/file1 -mksysb
Note: To restore a backup image on vio server, you have to use "installios" command in HMC. installios is a menu driven command (tool) which will ask for machine name, vio server(lpar) name, profile name for restoring the mksysb image.
The -i flag specifies that files will be read from standard input and archived by file name. The find command generates a list of all the files in the /home directory. The files in this list are full path names. The | (pipe symbol) causes this list to be read from standard input by the backup command. The -f flag directs the backup command to write the files to the /dev/rmt0 tape device. Because the files are archived using full path names, they will be written to the same paths when restored.
2. To backup all the files and subdirectories in the /home/mike directory using relative path names, enter:
Each file name in the list generated by the find command is preceded by ./ (dot, slash). Because the files are backed up using relative path names, they will be written to the current directory when restored. The -v flag causes the backup command to display additional information about the backup. The files are written to the default backup device /dev/rfd0.
The 0 level specifies that all the files in the / (root) file system be backed up. The -u flag causes the backup command to update the /etc/dumpdates file for this backup.
4. To backup all the files in the / (root) file system that have been modified since the last level 0 backup, enter:
If the /etc/dumpdates file does not have an entry for a level 0 backup of the / (root) system, all the files in the file system are backed up.
5. To create an archive with Extended Attributes and ACLs, enter:
ls /etc/passwd | backup -ivUf arch.bkBackup and Recovery
Backup rootvg using mksysbBackup and restore volume groups using savevg and restvg
restvg
backup
Restore files backed-up using mksysb/backup commands
Backup rootvg using mksysb
mksysb- Creates an installable image of the root volume group either in a file or on to a bootable tape
- Bootable tape is created in backup format
- Can be restored individual files/directories using restore command
mksysb
-e /excludes files in /etc/exclude.rootvg
-i to create image.data file
-v verbose mode
-X extend /tmp filesystem if necessory for storing boot image
-i option calls mkszfile command which inturn creats /image.data file.
The bootable mksysb volume contains four images
- Boot image
- bosinstall image (image.data, bosinst.data, tapeblksz, etc..)
- An empty table of contents
- System Backup Image in Back up format
/bosinst.data file contains answer for questions during installation time such as Console name, Installation methode, locale seetings, etc.. If there is no /bostinst.data file present, then a sample file /usr/lpp/bosinst/bosinst.template is copied as /bosinst.data during backup process.
/image.data file contains logical volume and filesystem information of root volume group which is used by BOS install for creating target rootvg. If you want to create a custom image.data file, create the file using mkszfile, modify the file as per your requirement and call the mksysb command without -i option.
With these two files, it is possible to carry out an un-attended installation.
Examples:
To create system backup and create an /image.data file
# mksysb -i /dev/rmt0
To exclude files and directories stored in /etc/exclude.rootvg file
# mksysb -i -e /dev/rmt0
To store the mksysb image to a file called /stage/backp/mksysb.img
# mksysb /stage/backp/mksysb.img
Backup or restore VGs using savevg and restvg
savevg command is used to backup volume groups other than rootvgrestvg command is used to restore volume groups other than rootvg
savevg
-e excludes files/directories being backed in /etc/exclude.<vgname> file
-i creates /tmp/vgdata/<vgname>/<vgname>.data file
-f <device> device or filename on which the image to be stored
-v verbose mode
-X automatically expand /tmp filesystem if required
-i option calls mkvgdata command which inturn creates /tmp/vgdata/<vgname>/<vgname>.data file
restvg
Backing up a filesytem or files
restore
-q tells restore commnad that volume is ready
-t, -T to list the list of files in the backup archive
-v verbose
-r restores all files in the filesystem archive
-x to restore specifig files/directories
-d to restore all files in a directory if the File parameter is a directory
-s <number> To seek and restore the multiple backup tapes
To list the names of files in either a file-name or file-system archive
# restore -Tq -f /dev/rmt0
To list all the files in a mksysb tape backup
# restore -Tvqs 4 -f /dev/rmt0.1
To restore an entire file-system archive, enter:
# restore -rvqdf /dev/rmt0
To restore a specific file
# restore -xvqf myhome.bkup system.data
To restore a specific file "/etc/passwd" from mksysb image file "mksysb.host1"
# restore -xvqdf mksysb.host1 ./etc/passwd
No comments:
Post a Comment