| 3 | | Notes for backing up directories can be found [http://www.astro.columbia.edu/~crussell/computing/notes/backup.note here]. |
| | 3 | Sample commands to tar files to tape. ( See /nfs/man/notes/solaris_tape.note |
| | 4 | for info on tape drives.) |
| | 5 | |
| | 6 | Note: **Commands below to create tar files will not follow any links - just the |
| | 7 | link file will be copied unless use the h switch. |
| | 8 | Also when extracting tar files, not all mode settings will be preserved unless |
| | 9 | use the p switch.** |
| | 10 | **To put more than one tar file per tape, use device name /dev/rmt/0n(n=norewind) |
| | 11 | and also the 'mt' command to position the tape past the last tar file written. |
| | 12 | See 'man mt'. and example 4) below.** |
| | 13 | |
| | 14 | 1) > cd /home/my_directory |
| | 15 | > tar cvf /dev/rmt/0 . (will put all files and subdirectories found |
| | 16 | in my_directory on the tape and rewind |
| | 17 | the tape) |
| | 18 | > cd /home/my_directory/subdirectory |
| | 19 | > tar xvf /dev/rmt/0 (will extract all files and subdirectories |
| | 20 | from the tar file on the tape and put them |
| | 21 | in the current directory) |
| | 22 | |
| | 23 | 2) > cd / |
| | 24 | > tar cvf /dev/rmt/0 usr home (will put directories usr and home |
| | 25 | and all subdirectories of usr and home on the |
| | 26 | tape and rewind the tape) |
| | 27 | > cd /tmp |
| | 28 | > tar xvf /dev/rmt/0 home (will extract directory home and all its |
| | 29 | subdirectories to the current directory) |
| | 30 | |
| | 31 | 3) Not a good idea to make a tar file from data begining with '/', for instance: |
| | 32 | tar cvf /dev/rmt/0 /home/carmen/wilds |
| | 33 | If you try to restore this, you will get permission denied errors. |
| | 34 | Instead, do: |
| | 35 | cd /home/carmen/wilds |
| | 36 | tar cvf /dev/rmt/0 . |
| | 37 | |
| | 38 | 4) To add data to a backup tape without overwriting its current contents: |
| | 39 | |
| | 40 | > mt -f /dev/rmt/0n eom (will space out past the EOF mark) |
| | 41 | > tar cvf /dev/rmt/0hn . > /tmp/newbackup.log & |
| | 42 | (will backup the current |
| | 43 | directory and all |
| | 44 | subdirectories below in |
| | 45 | compressed mode without |
| | 46 | rewinding first) |
| | 47 | See also: |
| | 48 | |
| | 49 | Sample script to dump a file system to tape. |
| | 50 | |
| | 51 | Script below copies four file systems to the same tape. A typical 8mm tape |
| | 52 | cartridge holds 5.0GB or 10GB in compressed mode. |
| | 53 | |
| | 54 | |
| | 55 | Use command: % ufsrestore -if /dev/rmt/0n |
| | 56 | to retrieve a file from a 'dump' tape later on. The ufsrestore command is |
| | 57 | convenient to use, see manual pages. |
| | 58 | |
| | 59 | #! /bin/csh |
| | 60 | # |
| | 61 | # Script ufsdump_alceste ***Note: Solaris 2.4 man ufsdump |
| | 62 | # says can detect end-of-media |
| | 63 | # so can use without s(size) |
| | 64 | # and d(density) parameters. |
| | 65 | # dump filesystems: |
| | 66 | # / /usr /usr/openwin /var /opt /home /var_ /src1 ...... |
| | 67 | # from alceste to local 10GB 8mm tape. |
| | 68 | # |
| | 69 | set d = `date` |
| | 70 | set bkup = /var/backup/alceste_m.log_{$d[2]}{$d[3]}{$d[6]} |
| | 71 | # |
| | 72 | echo Backup of alceste > $bkup |
| | 73 | date >> $bkup |
| | 74 | echo using ufsdump_alceste >> $bkup |
| | 75 | # |
| | 76 | echo Done on `date` >> $bkup |
| | 77 | #mt -f /dev/rmt/0cn eom # will take past last file written on tape. |
| | 78 | mt -f /dev/rmt/0c rewind |
| | 79 | mt -f /dev/rmt/0cn status >> $bkup |
| | 80 | |
| | 81 | #echo Tape at eom >> $bkup |
| | 82 | # |
| | 83 | echo ' ' >> $bkup |
| | 84 | ufsdump 0f /dev/rmt/0cn / >>& $bkup |
| | 85 | date |
| | 86 | echo ' ' >> $bkup |
| | 87 | ufsdump 0f /dev/rmt/0cn /home >>& $bkup |
| | 88 | date |
| | 89 | echo ' ' >> $bkup |
| | 90 | ufsdump 0f /dev/rmt/0cn /src1 >>& $bkup |
| | 91 | date |
| | 92 | echo ' ' >> $bkup |
| | 93 | ufsdump 0f /dev/rmt/0cn /src2 >>& $bkup |
| | 94 | date |
| | 95 | # |
| | 96 | echo ' ' >> $bkup |
| | 97 | # |
| | 98 | mt -f /dev/rmt/0c rewind |
| | 99 | date >> $bkup |
| | 100 | |
| | 101 | |
| | 102 | |
| | 103 | |
| | 104 | |
| | 105 | |
| | 106 | |
| | 107 | |
| | 108 | |
| | 109 | |
| | 110 | |
| | 111 | |