Various Backup Scripts ====================== (1) mt # mt -f /dev/rmt/0 status (to check status of backup device) # mt -f /dev/rmt/0n eom (to move to the end of tape) # mt -f /dev/rmt/0 rewind (to rewind) # mt -f /dev/rmt/0n fsf [count] (to jump [count] files) # mt -f /dev/rmt/0n bsf [count] (to forward [count] files) # mt -f /dev/rmt/0 erase (to delete tape) # mt -f /dev/rmt/0 offline (to eject) (2) tar # tar tvf /dev/rmt/0 (to check the tape) # tar xvf /dev/rmt/0 (to tar from tape to HD) # tar cvf /dev/rmt/0 /etc/hosts (to tar files and directory to tape) /etc/host and ./inet/hosts are symbolic linked # tar rvf /dev/rmt/0 group (to replace at the end of tarfile) # tar cvfb - 20 files | rsh host dd of=/dev/rmt/0 obs=20b (to backup to a drive in remote host) # rsh -n host dd if=/dev/rmt/0 bs=20b |tar xvBfb - 20 files (to backup to a drive in remote host) (3) ufsdump (3a) For single file system # ufsdump 0ucf /dev/rmt/0n /dev/rdsk/c0t0d0s0 (for full dump) DUMP: Writing 63 Kilobyte records DUMP: Date of this level 0 dump: DUMP: Date of last level 0 dump: the epoch DUMP: Dumping /dev/rdsk/c0t0d0s0 (blue:/) to /dev/rmt/0n. DUMP: Mapping (Pass I) [regular files] DUMP: Mapping (Pass II) [directories] DUMP: Estimated 1703122 blocks (831.60MB). DUMP: Dumping (Pass III) [directories] DUMP: Dumping (Pass IV) [regular files] DUMP: 63.88% done, finished in 0:05 DUMP: 1703014 blocks (831.55MB) on 1 volume at 793 KB/sec DUMP: DUMP IS DONE (3b) ufsdump option 0 : full dump 1 - 9 : gradual backup based from /etc/dumpdate u : record at /etc/dumpdate c : Catridge, (for 1000BPI density and 126 blocking factor) l : Autoload of next tape when tape ends before dumping finished. v : verify S : calculate capacity. f dump_file : record file image to dump_file w : /etc/dumpdatež shows ufs system which is not dumped yet # ufsdump 0Sf /dev/rmt/0 /dev/rdsk/c0t0d0s0 873689088 # ufsdump w Dump these file systems: /dev/rdsk/c0t0d0s0 ( /) Last dump: Level 0, Date Wed Apr 29 12:50 /dev/rdsk/c0t0d0s7 (/export/home) Last dump: Level 0, Date Sat May 2 12:57 /dev/rdsk/c0t1d0s0 ( ) Last dump: Level 0, Date Wed Apr 29 11:23 # cat dumpdates /dev/rdsk/c0t0d0s0 0 Wed Apr 29 12:50:50 1998 /dev/rdsk/c0t0d0s7 0 Sat May 2 17:20:01 1998 /dev/rdsk/c0t1d0s0 0 Wed Apr 29 11:23:19 1998 (3c) For multiple file systems into one tape # ufsdump 0ucf /dev/rmt/0n /dev/rdsk/c0t0d0s0;ufsdump 0ucf \ /dev/rmt/0n /dev/rdsk/c0t0d0s7 DUMP: Writing 63 Kilobyte records DUMP: Date of this level 0 dump: DUMP: Date of last level 0 dump: the epoch DUMP: Dumping /dev/rdsk/c0t0d0s0 (blue:/) to /dev/rmt/0n. DUMP: Mapping (Pass I) [regular files] DUMP: Mapping (Pass II) [directories] DUMP: Estimated 1703122 blocks (831.60MB). DUMP: Dumping (Pass III) [directories] DUMP: Dumping (Pass IV) [regular files] DUMP: 63.88% done, finished in 0:05 DUMP: 1703014 blocks (831.55MB) on 1 volume at 793 KB/sec DUMP: DUMP IS DONE DUMP: Level 0 dump on (date) DUMP: Writing 63 Kilobyte records DUMP: Date of this level 0 dump: DUMP: Date of last level 0 dump: the epoch DUMP: Dumping /dev/rdsk/c0t0d0s7 (blue:/export/home) to /dev/rmt/0n. DUMP: Mapping (Pass I) [regular files] DUMP: Mapping (Pass II) [directories] DUMP: Estimated 303300 blocks (148.10MB). DUMP: Dumping (Pass III) [directories] DUMP: Dumping (Pass IV) [regular files] DUMP: 303280 blocks (148.09MB) on 1 volume at 1269 KB/sec DUMP: DUMP IS DONE (4) ufsrestore (4a) Restoring Entire File System # mount /dev/dsk/c0t0d0s7 /export/home # cd /export/home # mt -f /dev/rmt/0n fsf 1 (to move to next point) # ufsrestore rvf /dev/rmt/0n Verify volume and initialize maps Media block size is 126 Dump date: Sat May 02 12:57:43 1998 Dumped from: the epoch Level 0 dump of /export/home on blue:/dev/dsk/c0t0d0s7 Label: none Begin level 0 restore Initialize symbol table. Extract directories from tape Calculate extraction list. Warning: ./lost+found: File exists Make node ./cyberguy Make node ./dsw Make node ./dsw/core Make node ./crash Make node ./crash/blue Make node ./test Extract new leaves. Check pointing the restore extract file ./.CPR extract file ./dsw/core/unix.2 extract file ./dsw/core/vmcore.2 extract file ./dsw/core/threadlist.0 extract file ./dsw/core/threadlist.2 extract file ./crash/blue/vmcore.0 extract file ./crash/blue/unix.0 extract file ./crash/blue/bounds extract file ./crash/blue/threadlist.0.org extract file ./crash/blue/threadlist.0 Add links Set directory mode, owner, and times. Check the symbol table. Check pointing the restore blue# pwd /export/home blue# ls crash dsw restoresymtable cyberguy lost+found test blue# rm restoresymtable (4b) ineractive restore # cd /var/tmp # ufsrestore ivf /dev/rmt/0 Verify volume and initialize maps Media block size is 126 Dump date: Mon May 11 14:33:16 1998 Dumped from: the epoch Level 0 dump of /user on blue:/dev/dsk/c0t1d0s3 Label: none Extract directories from tape Initialize symbol table. ufsrestore > ls .: ufsrestore > cd lost+found ufsrestore > cd / ufsrestore > add passwd lost+found ufsrestore > verbose verbose mode off ufsrestore > verbose verbose mode on ufsrestore> delete lost+found ufsrestore > ls .: ufsrestore > extract Extract requested files You have not read any volumes yet. Unless you know which volume your file(s) are on you should start with the last volume and work towards the first. Specify next volume #: 1 extract file ./passwd Add links Set directory mode, owner, and times. set owner/mode for '.'? [yn] n ufsrestore > quit (4c) To restore files # ufsrestore xvf /dev/rmt/0 ./etc/passwd (4d) To display the content of the tape # ufsrestore tvf /dev/rmt/0 (5) cpio commands # find . -print | cpio -ovcB > /dev/rmt/0 (to copy current directory to tape) . upgrade upgrade/Agree.ps upgrade/Announcement.ps upgrade/Program.ps upgrade/Refund.ps upgrade/URCFORM.ps array array/DECptscII array/DECptscII/pkgmap array/DECptscII/pkginfo array/DECptscII/root array/DECptscII/root/kernel array/DECptscII/root/kernel/drv array/DECptscII/root/kernel/drv/classes array/DECptscII/root/kernel/drv/ptscII.52 array/DECptscII/root/kernel/drv/ptscII.53 array/DECptscII/install array/DECptscII/install/copyright array/DECptscII/install/postinstall array/DECptscII/install/preremove array/DECstgwks array/DECstgwks/pkgmap array/DECstgwks/pkginfo array/DECstgwks/root array/DECstgwks/root/$TRANSDIR array/DECstgwks/root/$TRANSDIR/sd.conf array/DECstgwks/root/$TRANSDIR/trans.Z array/DECstgwks/root/$TRANSDIR/trans.conf # cpio -ivcB array/DECstgwks/install/foobar < /dev/rmt/0 (to extract foobar from tape) array/DECstgwks/install/space 8550 blocks # find . -mtime -7 -print | cpio -ovcB > /dev/rmt/0n (to copy files which was modified within the last seven days) . upgrade upgrade/Agree.ps upgrade/Announcement.ps upgrade/Program.ps upgrade/Refund.ps # find . -name 'file*' -print | cpio -ovcB > file.list # cpio -ivt < file.list (6) Backup script sample #!/bin/csh set verbose set day = `date +%y%m%d` mt -f /dev/rmt/0n rew ufsdump 0uf /dev/rmt/0bn / ufsdump 0uf /dev/rmt/0bn /usr ufsdump 0uf /dev/rmt/0bn /var ufsdump 0uf /dev/rmt/0bn /export/home ufsdump 0uf /dev/rmt/0bn /opt echo "now test the backups." mt -f /dev/rmt/0n rew;ufsrestore tfs /dev/rmt/0n 1 > \ /export/home/bert/dumpfile1.${day} mt -f /dev/rmt/0n rew;ufsrestore tfs /dev/rmt/0n 2 > \ /export/home/bert/dumpfile2.${day} mt -f /dev/rmt/0n rew;ufsrestore tfs /dev/rmt/0n 3 > \ /export/home/bert/dumpfile3.${day} (7) Sun O/S backup parameter High density Fujitsu/Xylogics 1/2" tape # dump 0uf /dev/rmt8 /dev/rxy0 600' QIC-24 9 track 1/4" cartridge tape # dump 0ucf /dev/nrst8 /dev/rds0h QIC-150 18 track 1/4" catridge tape: # dump 0ucsf 1500 /dev/rst0 /dev/rsd0h Exabyte 8mm catridge tape: # dump 0usf 145000 /dev/rst0 /dev/rid001h ==========================================