Register
It is currently Mon Apr 21, 2014 9:27 am

Snapshot backup deleting directories


All times are UTC - 6 hours


Post new topic Reply to topic  [ 5 posts ] 
Author Message
 PostPosted: Wed May 25, 2011 2:12 am   

Joined: Wed May 25, 2011 2:02 am
Posts: 2
Can anyone help me please by looking at my snapshot backup script. It should be taking a daily snapshot of my core libraries and backing them up with
an RSYNC --link-dest. It should keep 5 days worth of backups.

What I find is that if I call the job from CRON it runs OK and I get my backup libraries correctly created but at some point if I leave the process to run it
starts deleting the backup libraries and then just runs through without doing anything i.e. 0 minutes to complete.

Excuse the primitive code but if anyone can tell me what is wrong with it I would be very grateful. Any tips on tidying up the code and adding in "traps"
or console messages for better debugging would also be gratefully received !

:START

#!/bin/bash -xv

# DAILY SNAPSHOT BACKUP
# run from Monday to Friday

SOURCE=/mnt/NASHD/users/
TARGET=/mnt/NASHD/.snap
LOGS=/mnt/NASHD/users/support/tools/LOGS
LOGFILE=rsync.DAILY
STARTMSG="Starting SNAPSHOT DAILY:"
ENDMSG="Completed SNAPSHOT DAILY"
NEWLINE="\n"
# RUNTIME=$(date +%d-%b-%Y)
RUNTIME=$(date)


# Cull previous log. We don't want these to get too big !

rm -v $LOGS/$LOGFILE


# Tell syslog and write to log file, snapshot is starting

logger $STARTMSG $RUNTIME
echo -e $STARTMSG $RUNTIME $NEWLINE > $LOGS/$LOGFILE

echo SOURCE rsync directory is: $SOURCE >> $LOGS/$LOGFILE
logger "SOURCE rsync directory is: $SOURCE"

echo -e TARGET rsync directory is: $TARGET >> $LOGS/$LOGFILE
logger "TARGET rsync directory is: $TARGET"

echo -e LOG directory is: $LOGS/$LOGFILE $NEWLINE >> $LOGS/$LOGFILE
logger "LOG file is: $LOGS/$LOGFILE"



rm -rf $TARGET/daily.5

mv $TARGET/daily.4 $TARGET/daily.5
mv $TARGET/daily.3 $TARGET/daily.4
mv $TARGET/daily.2 $TARGET/daily.3

# cp -v -al $TARGET/daily.1 $TARGET/daily.2
# rsync --log-file=$LOGS/$LOGFILE -aPv --delete-after --safe-links --stats $SOURCE $TARGET/daily.1/


# RSYNC using the link-dest option:
#
# This option behaves like --copy-dest, but unchanged files are
# hard linked from DIR to the destination directory. The files
# must be identical in all preserved attributes (e.g. permissions,
# possibly ownership) in order for the files to be linked
# together. An example:
#
# rsync -av --link-dest=$PWD/prior_dir host:src_dir/ new_dir/
#

mv $TARGET/daily.1 $TARGET/daily.2

rsync --log-file=$LOGS/$LOGFILE -aPv --delete --safe-links --stats --link-dest=$TARGET/daily.2 $SOURCE $TARGET/daily.1/


# Send completion message to syslog and log file

echo -e $NEWLINE $ENDMSG >> $LOGS/$LOGFILE
logger $ENDMSG

:END


Top
 Profile  
 PostPosted: Wed May 25, 2011 12:06 pm   
User avatar

Joined: Sun Jun 27, 2010 12:57 am
Posts: 192
I DON'T LIKE SHOUTY SUBJECTS, SO I"M NOT GOING TO ANSWER HERE.


Top
 Profile  
 PostPosted: Thu Jun 02, 2011 7:02 am   

Joined: Wed May 25, 2011 2:02 am
Posts: 2
If you don't understand the post then ask and I'll explain it to you...

If you have nothing to say then please don't waste my time find something more useful to do with your life
you sad puppy !!!


Top
 Profile  
 PostPosted: Thu Jun 02, 2011 10:23 am   
User avatar

Joined: Sun Jun 27, 2010 12:57 am
Posts: 192
thylacine wrote:
If you don't understand the post then ask and I'll explain it to you...

If you have nothing to say then please don't waste my time find something more useful to do with your life
you sad puppy !!!


Ohw I understand your post quite well, but you don't seem to understand my answer.
And calling people names isn't going to get you any favor points with the helping hands on this forum either.


Top
 Profile  
 PostPosted: Tue Jun 07, 2011 9:58 am   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 657
Location: Des Moines, Iowa
thylacine wrote:
If you don't understand the post then ask and I'll explain it to you...

If you have nothing to say then please don't waste my time find something more useful to do with your life
you sad puppy !!!



(me either.... I edited the title ... no more caps --- Crouse)


Top
 Profile WWW  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP