Jump to content
Slate Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate Marble
Slate Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate Marble
Sign in to follow this  
glaukos

LinuxStories: Backup in Tape Device

Recommended Posts

Bash shell script for take Backup in Tape Device 

#!/bin/sh
#

#
#Set Device
TAPE=/dev/rmt/0
#Set Source Path where take backup
DIR=/files
#Set Log Directory
LOGDIR=/var/log/backup
#Set Logfile Name
LOGFILE=$LOGDIR/backup_`date '+%Y%m%d'`
 

#=====================================
# Please do not remove anything from
# below lines!!!!!
#=====================================
#
echo "`date '+%Y%m%d-%H%M'` Starting backup to tape ..." >> $LOGFILE 2>&1

find $LOGDIR -name backup_\* -mtime +7 -exec rm {} \;

mt -f $TAPE rewind > /dev/null 2>&1
tape_status=$?

if [ $tape_status -ne 0 ]; then
  echo "`date '+%Y%m%d-%H%M'` Tape drive problem ..." >> $LOGFILE 2>&1
  exit 1
fi

mt -f $TAPE rewind > /dev/null 2>&1
echo "`date '+%Y%m%d-%H%M'` Starting tar ..." >> $LOGFILE 2>&1
tar cvf $TAPE $DIR >> $LOGFILE 2>&1
echo "`date '+%Y%m%d-%H%M'` Finished tar and ejecting tape ..." >> $LOGFILE 2>&1

mt -f $TAPE offline

View the full article

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×