your backup utility
jose sanchez
j_r_sanchez at yahoo.com
Thu Jan 3 20:12:44 CST 2002
Matt:
I have to try that. Now I have another problem with
the tar command which I will CC the list:
Does tar/gzip has a file size limitation? I can only
tar -czf up to 2.0GB. I am trying to backup our NT
server which has a little over 6.0GB of data. When I
run the script with crontab it sends me an email
saying:
gzip: stdout: File too large
What can be done to get around this. Is there another
flag I need?
Here's the script:
#!/bin/bash
#
##########################################################################
# Filename: backupNT
# Description: This script will first mount the
necessary drives from
# the file server SERVER1 - 192.168.1.2 - P and S
with
# the mount command with Samba file system. Then it
will
# back up all the data from the drives with the tar
command.
# Version: 1.1
# Date: December 17, 2001
# Author: J. Wilson Sanchez
# Company: SafeTECH International, Inc.
##########################################################################
##############################
# Function Declaration
##############################
#
##############################
# ----------------------------
# toMount function:
# Receives:
# Returns:
function toMount () {
echo "*** Mounting $REMOTE_DRIVE Drive..." >>
$MAIL_FILE
mount -t smbfs -o
username=$ADMIN,password=$ADMIN_PASS
//$CLIENT_BOX_NAME/$REMOTE_DRIVE /$LOCAL_DRIVE -o ro
if [ $? = 0 ]; then
echo "Done..." >> $MAIL_FILE
else
echo "*** ERROR: Couldn't mount $REMOTE_DRIVE..."
>> $MAIL_FILE
fi
}
# ----------------------------
# UnMount function:
function uMount (){
echo "*** Unmounting $LOCAL_DRIVE Drive..." >>
$MAIL_FILE
umount $LOCAL_DRIVE
if [ $? = 0 ]; then
echo "Done..." >> $MAIL_FILE
else
echo "*** ERROR: Couldn't UnMount $LOCAL_DRIVE..."
>> $MAIL_FILE
fi
}
# ----------------------------
# movePrevBak function moves yesterday's backup to
folder /Backedup/prev
function movePrevBak () {
echo "*** Moving yesterday's backup to
/Backedup/prev..." >> $MAIL_FILE
mv -f --target-directory=/Backedup/prev
/Backedup/*.*.*
if [ $? = 0 ]; then
echo "Done..." >> $MAIL_FILE
else
echo "*** ERROR: Couldn't move files. Directory
maybe empty..." >> $MAIL_FILE
fi
}
# ----------------------------
# backItUp function
# Function zips and compresses the backup.
function backItUp () {
echo "*** Starting to Backup $REMOTE_DRIVE drive..."
>> $MAIL_FILE
tar czf /Backedup/$TAR_FILE_NAME /$LOCAL_DRIVE/*
if [ $? = 0 ]; then
echo "Done..." >> $MAIL_FILE
else
echo "*** ERROR: Compression not done..." >>
$MAIL_FILE
fi
}
##############################
# Global Variables
##############################
CLIENT_BOX_NAME=SERVER1 # Name of the box to be
backed up
CLIENT_BOX_IP=192.168.1.2 # IP Address of the box
ADMIN=server1 # Administrator USERNAME
ADMIN_PASS=
REMOTE_DRIVE=0 # This will be the drive to be
backedup
LOCAL_DRIVE=0 # The Mount to drive
DATE=`eval date +%D:%r` # Set Date - notice ` not '
DATE2=`eval date +%A` # Day of week: Monday, etc...
TAR_FILE_NAME=name.tar.gz # Name of the tarred file:
name.tar.gz
##############################
# Make log files
##############################
#
# forMail_log is used for the email sent at the end of
the script.
# If file exists rename it with today's date append it
to the end.
MAIL_FILE=/BackupLogs/forMail_log # File location
##############################
# Prepare forMail_log headers
##############################
#
echo "$DATE --- Nightly Backup" > $MAIL_FILE
echo "============================" >> $MAIL_FILE
##############################
# Backup P
##############################
#
TAR_FILE_NAME=driveP.tar.gz
REMOTE_DRIVE=P
LOCAL_DRIVE=/P
movePrevBak
toMount
backItUp
uMount
##############################
# Backup S
##############################
#
TAR_FILE_NAME=driveS.tar.gz
REMOTE_DRIVE=S
LOCAL_DRIVE=/S
movePrevBak
toMount
backItUp
uMount
##############################
# Finished Backing UP
##############################
#
echo "Finished Backing up at: `eval date +%r`" >>
$MAIL_FILE
echo "Sending this email..." >> $MAIL_FILE
mail -s "$DATE Backup Report" wilson at safetechintl.com
< $MAIL_FILE
#
----------------------------------------------------------------------------------------
exit 0
# ---------------------------------------------
Thanks
--- crash3m <crash3m at yahoo.com> wrote:
> I kept thinking about your problem and it irritated
> me that it should work
> but doesn't, so I jumped on irc and asked around.
> heres a copy of the log
>
> <crash3m> is there any reason why 'tar cvf file.tar
> /sambamount' would miss
> some folders and files?
> <Verloc> not that I can think of
> <owen> crash3m: permissions
> <crash3m> owen: permissions on a samba share?
> <owen> on the files
> <owen> but it would generate errors
> <owen> ie, you dont have read access on a file...it
> will say Permission Denied
> <crash3m> the samba share is mounted as
> administrator, and tar is ran as root
> <owen> i dunno
> <owen> it might miss hidden files
> <crash3m> the directories it's missing are not
> hidden
> <crash3m> not attributed in any way either
> <Verloc> that's fucked
> <-- xplo has quit (".")
> <Loki> Parent directories are executable?
> <owen> just do an tar cvf smb.tar `ls -R
> /sambamount`
>
> hopefully that last line is what you need
>
>
>
> On Thursday 03 January 2002 11:50 am, you wrote:
> > I read the man page last night too and I came up
> with
> > the same thought: use the -d flag to compare. I'll
> try
> > that sometime and i'll let you know.
> >
> > Thanks
> >
> > --- crash3m <crash3m at yahoo.com> wrote:
> > > I checked out the man page for tar, -R is not
> > > recursive, there is no such
> > > function, the only thing I can think of is to
> use
> > > the -d flag with tar to
> > > find the differences between your archive and
> the
> > > file system, then have tar
> > > catenate (-A) the files mentioned from the diff
> into
> > > the original tar.
> > >
> > > Matt Luettgen
> >
> >
>
_________________________________________________________
> >
> > > Do You Yahoo!?
> > > Get your free @yahoo.com address at
> > > http://mail.yahoo.com
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Send your FREE holiday greetings online!
> > http://greetings.yahoo.com
>
>
_________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at
> http://mail.yahoo.com
>
__________________________________________________
Do You Yahoo!?
Send your FREE holiday greetings online!
http://greetings.yahoo.com
More information about the Kclug
mailing list