Sunday, December 11, 2011

Backup commands in AIX

mksysb -i -X /dev/rmt0        Creates image.data and system backup (-X expands /tmp if required)

mksysb -m /dev/rmt0        Creates image.data file with map file and system backup

mksysb -e /dev/rmt0        Creates system data but excludes the files listed in /etc/exclude.rootvg

mkszfile                Creates /image.data file

mkcd -d /dev/cd1            Creates system boot backup to the CD-R device /dev/cd1    (mksysb)
mkcd -d /dev/cd1 -v datavg        Creates  backup of VG datavg to CD-R device /dev/cd1   (savevg)
savevg -i -f /dev/rmt0 datavg    Creates datavg.data image file and backup vg datavg (path = /tmp/vgdata/datavg/datavg.data)
savevg -ef  /dev/rmt0 datavg        Creates datavg backup but excludes files listed in the /etc/exclude.datavg

find / -print | backup -ivf /dev/rmt0    Backup entire system to rmt0

backup -0vf /dev/rmt0 /home    Backup /home directory to rmt0 with backup level 0
restore -Tvf /dev/rmt0        List the archive in rmt0

restore -xvf /dev/rmt0 /home    Restore /home from archive in device rmt0

restore –xvf /export/mksysb ./etc/sshd.conf    Restores particular file from /export/mksysb image

restore -Pa -vf /dev/rmt0 ./etc/passwd    Restore only a file attribute from tape

 find ./home -print |cpio -ocvumB > /dev/rmt0  Archives /home directory 

cpio -icvdumB < /dev/rmt0  Restores cpio archive from rmt0

cpio -ivt < /dev/rmt0      List the contents of cpio archive from rmt0

cpio -icvd < /dev/rmt0 /home  Restores /home directory from rmt0

tar -cvf /dev/rmt0 /home        Archives /home to rmt0 device

tar -tvf /dev/rmt0            List the archives in rmt0

tar -xvf /dev/rmt0 /home        Extract /home from rmt0

dd if=file1 of=file2 conv=ebcdic    Convert and copy ascii file to ebcdic file2

dd count=1 bs=4k skip 31 seek=1 if=/dev/hd4 of=/dev/hd4    copy 31st block and paste to 1st block in the hd4 ( ie.to fix currupted superblock by restoring it's backup copy to original location)
dd if=/dev/rmt0 ibs=512 obs=1024 of=/dev/rmt1  To copy blocks from rmt0 with 512 blocks to rmt1 with 1024 blocks 

tctl -f /dev/rmt0 rewind        To rewind the tape

tctl -f /dev/rmt0 offline        To eject the tape

tctl -f /dev/rmt0 status        To show the status of tape

tcopy /dev/rmt0.0 /dev/rmt1.0   to copy contents of 1st tape(tape0) to 2nd tape(tape1). It is useful when the size of the tapes are different.

tcopy /dev/rmt0     to show no. of files and block size in the tape
chdev -l rmt0 -a block_size=512    To change the block size of the tape to 51201