Tape drive backup and Restore
Hi ...
Am using ultrium LTO4 sas IBMtape drive in RHEL 5.5 for backup. Device name is /dev/IBMtape0 Someone has written a script for backup as monday is full backup and for rest of the days partial backup, used the below command in the script for backup. $TAR $TAR_ARGS -cvzpf $TAPE $DIR $BACKUP_ROOT_DIR when i issue tar -tvzf it lists files in the tape. when i issue tar -tvzf it lists files in the tape. but how can i know which date backup it is listing. Please tell me how to create a directory with date in tape drive so backup should go into the created directory. And also please tel me how to restore files from tape drive. Thank you for all. |
The command
Code:
tar -tvzf path_to_tape If you want to extract you substitute the t with x; however, that will extract everything (which you may not want). To extract one file from the archive you would use Code:
tar xzvf archive_name file_name_in_archive Code:
tar -tvzf moneydance_other.tar.gz moneydance/moneydance.xpm The above is the GNU version of tar (but most will work like this). You may want to read the manual page for tar or the info page for tar or, using Google, search for "linux tar." Here is one page that you may find useful (and full of examples) http://www.computerhope.com/unix/utar.htm. Hope this helps some. |
Tape drive backup and restore
Hi..
Really helpfull information. Here is the thing. Script had the line $TAR $TAR_ARGS -cvpf $TAPE $BACKUP_ROOT_DIR(with no archive name) As i wanted to create a compressed archive in the tape so modified it as #name for the archive in the tape DIR=mkdir TEST_BKP_$(date '+%d%m%Y') $TAR $TAR_ARGS -cvzpf $TAPE $DIR $BACKUP_ROOT_DIR Still couldn't able to find the name of the archive or directory in the tape.(only listing files) I think archive is not being created in the tape. please guide me how to create a archive name with current date in the tape. (Where archive name should be mentioned in the below tar line) $TAR $TAR_ARGS -cvpf $TAPE $BACKUP_ROOT_DIR. Also when i extract file from tape which location file will be placed. (I mean whether in the present working directory where issuing the command or in the original location) Thanks... |
The way your shell program is written, the first argument to the tar command ($TAR) is the tape drive ($TAPE); i.e., /dev/IBMtape0. So, the tape is the tape archive (that's what tar means, an acronym of tape archive. So, what you see on the tape is a list of directory and file names that are a copy of the location (directory) and content (file).
The other way to look at that is if you used tar to create a file named, say, 2012-06-14.tar (for example) somewhere on your disk drive(s) then compress that into what's called a tarball (say, 2012-06-14.tar.gz) then copy that to the tape as one big (but compressed) tar archive. You'd do that something like this Code:
tar cvf 2012-06-14.tar $DIR $BACKUP_ROOT_DIR You have to consider, though, whether you have sufficient room on the tape for more than one back up of the system root (or whatever file tree on the disk drive) directory (some tape systems do, some don't, some will write on more than one cartridge, some won't). It may be simpler to, you know, write the date on the label and be done with it. A slick way to create the archive file name is Code:
tar -cvf `date +%F`.tar.gz <other arguments> Code:
tar -cvf /tmp/`date +%F`.tar <other arguments> Now, let's combine stuff. You can compress on-the-fly by adding z for gzip or j for bzip2 in the tar arguments: Code:
tar -czvf /tmp/`date +%F`.tar.gz <other arguments> You might want to avoid the v (which shows you the file names) unless you're keeping a log. So, all in one go Code:
# Create a date stamp name for the archive Hope this helps some. |
Just a comment on post #3
Code:
# this doesn't work Also Code:
$TAR $TAR_ARGS -cvpf '-cvpf' are the options.. I think you meant Code:
TAR_ARGS=-cvpf |
Got it...
See the script for the full backup and partial backup. For partial backup aleso tar acrchive will be created..? And please correct if the script is wrong anad also when i type mt -f /dev/IBMtape0 erase it took hours and get device busy.. How to delete a tar archive,files, directories in the Tape. # Backup logs are stored here LOGBASE=/root/backup/log # Backup dirs; do not prefix / BACKUP_ROOT_DIR="u05 " # Get todays day like Mon, Tue and so on NOW=$(date +"%a") # Tape device name TAPE="/dev/IBMtape0" # Exclude file TAR_ARGS="" EXCLUDE_CONF=/root/.backup.exclude.conf # Backup Log file LOGFIILE=$LOGBASE/$NOW.backup.log # Path to binaries TAR=/bin/tar MT=/bin/mt MKDIR=/bin/mkdir # ------------------------------------------------------------------------ # Excluding files when using tar # Create a file called $EXCLUDE_CONF using a text editor # Add files matching patterns such as follows (regex allowed): # home/vivek/iso # home/vivek/*.cpp~ # ------------------------------------------------------------------------ [ -f $EXCLUDE_CONF ] && TAR_ARGS="-X $EXCLUDE_CONF" #### Custom functions ##### # Make a full backup full_backup(){ local old=$(pwd) # Create a date stamp name for the archive FILE_NAME=/tmp/`date +%F`.tar.gz # Create a gzip tar archive in /tmp/yyyy-mm-dd.tar.gz tar czf $FILE_NAME $DIR $BACKUP_ROOT_DIR # Copy the archive file to tape cp $FILE_NAME $TAPE # Remove the archive file rm $FILE_NAME $MT -f $TAPE rewind $MT -f $TAPE offline cd $old } [ $? -eq 0 ] && status="Success!" || status="Failed!!!" mail -s 'Backup status=$status' < mail id> The backup job finished. End date: $(date) Hostname : $(hostname) Status : $status # Make a partial backup partial_backup(){ local old=$(pwd) cd / $TAR $TAR_ARGS -cvzpf $TAPE -N "$(date -d '1 day ago')" $BACKUP_ROOT_DIR $MT -f $TAPE rewind $MT -f $TAPE offline cd $old } [ $? -eq 0 ] && status="Success!" || status="Failed!!!" mail -s 'Backup status' <mail id> The backup job finished. End date: $(date) Hostname : $(hostname) Status : $status # Make sure all dirs exits verify_backup_dirs(){ local s=0 for d in $BACKUP_ROOT_DIR do if [ ! -d /$d ]; then echo "Error : /$d directory does not exits!" s=1 fi done # if not; just die [ $s -eq 1 ] && exit 1 } #### Main logic #### # Make sure log dir exits [ ! -d $LOGBASE ] && $MKDIR -p $LOGBASE # Verify dirs verify_backup_dirs # Okay let us start backup procedure # If it is monday make a full backup; # For Tue to Fri make a partial backup # Weekend no backups case $NOW in Mon) full_backup;; Tue|Wed|Thu|Fri) partial_backup;; *) ;; esac > $LOGFIILE 2>&1 |
All times are GMT -5. The time now is 06:41 PM. |