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.

Place all files and subdirectories found in my_directory on the tape and rewind the tape

> cd /home/my_directory
> tar cvf /dev/rmt/0 . 		

Extract all files and subdirectories from the tar file on the tape and put them in the current directory

> cd /home/my_directory/subdirectory
> tar xvf /dev/rmt/0		

Place directories usr and home and all subdirectories of usr and home on the tape and rewind the tape

> cd /
> tar cvf /dev/rmt/0  usr  home       

Extract directory home and all its subdirectories to the current directory

> cd /tmp
> tar xvf /dev/rmt/0	home		

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 .

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)

Backup the current directory and all subdirectories below in compressed mode without rewinding first

> tar cvf /dev/rmt/0hn  . > /tmp/newbackup.log &

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