| Version 8 (modified by , 20 years ago) ( diff ) |
|---|
Backing up Directories
Sample commands to tar files to tape. ( See /nfs/man/notes/solaris_tape.note
for info on tape drives.)
Note:
- Commands below to create tar files will not follow any links - just the
link file will be copied unless use the h switch. Also when extracting
tar files, not all mode settings will be preserved unless
use the p switch.
- To put more than one tar file per tape, use device name /dev/rmt/0n(n=norewind)
and also the 'mt' command to position the tape past the last tar file written. See 'man mt'. and example (4) below.
1
> cd /home/my_directory > tar cvf /dev/rmt/0 . (will put all files and subdirectories found in my_directory on the tape and rewind the tape) > cd /home/my_directory/subdirectory > tar xvf /dev/rmt/0 (will extract all files and subdirectories from the tar file on the tape and put them in the current directory)
2
> cd / > tar cvf /dev/rmt/0 usr home (will put directories usr and home and all subdirectories of usr and home on the tape and rewind the tape) > cd /tmp > tar xvf /dev/rmt/0 home (will extract directory home and all its subdirectories to the current directory)
3
Not a good idea to make a tar file from data begining with '/', for instance:
tar cvf /dev/rmt/0 /home/carmen/wilds (If you try to restore this, you will get permission denied errors.) Instead, do: cd /home/carmen/wilds tar cvf /dev/rmt/0 .
4
To add data to a backup tape without overwriting its current contents:
> mt -f /dev/rmt/0n eom (will space out past the EOF mark) > tar cvf /dev/rmt/0hn . > /tmp/newbackup.log & (will backup the current directory and all subdirectories below in compressed mode without rewinding first) See also: Sample script to dump a file system to tape. Script below copies four file systems to the same tape. A typical 8mm tape cartridge holds 5.0GB or 10GB in compressed mode. Use command: % ufsrestore -if /dev/rmt/0n to retrieve a file from a 'dump' tape later on. The ufsrestore command is convenient to use, see manual pages.
#! /bin/csh
#
# Script ufsdump_alceste ***Note: Solaris 2.4 man ufsdump
# says can detect end-of-media
# so can use without s(size)
# and d(density) parameters.
# dump filesystems:
# / /usr /usr/openwin /var /opt /home /var_ /src1 ......
# from alceste to local 10GB 8mm tape.
#
set d = `date`
set bkup = /var/backup/alceste_m.log_{$d[2]}{$d[3]}{$d[6]}
#
echo Backup of alceste > $bkup
date >> $bkup
echo using ufsdump_alceste >> $bkup
#
echo Done on `date` >> $bkup
#mt -f /dev/rmt/0cn eom # will take past last file written on tape.
mt -f /dev/rmt/0c rewind
mt -f /dev/rmt/0cn status >> $bkup
#echo Tape at eom >> $bkup
#
echo ' ' >> $bkup
ufsdump 0f /dev/rmt/0cn / >>& $bkup
date
echo ' ' >> $bkup
ufsdump 0f /dev/rmt/0cn /home >>& $bkup
date
echo ' ' >> $bkup
ufsdump 0f /dev/rmt/0cn /src1 >>& $bkup
date
echo ' ' >> $bkup
ufsdump 0f /dev/rmt/0cn /src2 >>& $bkup
date
#
echo ' ' >> $bkup
#
mt -f /dev/rmt/0c rewind
date >> $bkup
Note:
See TracWiki
for help on using the wiki.
