Friday, May 06, 2011

Shell Script To Backup To Tape Drive - Linux

#!/bin/bash
# A simple shell script to backup dirs to tape drive.
# -------------------------------------------------------------------------
# Copyright (c) 2005 nixCraft project <http://cyberciti.biz/fb/>
# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit http://bash.cyberciti.biz/ for more information.
# -------------------------------------------------------------------------
MT=/bin/mt
TAR=/bin/tar
LOGGER=/usr/bin/logger
 
# What to backup.
SOURCE_DIRS="/data /home /etc /root /www"
 
# Where to backup to.
TAPE="/dev/st0"
 
# log message
$LOGGER "Backing $SOURCE_DIRS to $TAPE @ $(date)"
 
# Rewind the tape
$MT -f $TAPE rewind
 
# Backup the files
$TAR czf $TAPE $SOURCE_DIRS
 
# Rewind and eject the tape
$MT -f $TAPE rewoffl
# log message
$LOGGER "Backup finished @ $(date)"
 
 
 
Regards,
Sukhwinder Singh 

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.