WCM - Das österreichische Computer Magazin Forenübersicht
 

Zurück   WCM Forum > Rat & Tat > Linux, UNIX, Open Source

Linux, UNIX, Open Source Rat & Tat bei Problemen und Fragen rund um GNU/Linux, BSD und sonstige UNIXe

Microsoft KARRIERECAMPUS

 
 
Themen-Optionen Ansicht
Alt 08.05.2005, 18:29   #5
Theodor
Newbie
 
Registriert seit: 08.05.2005
Alter: 57
Beiträge: 6


Standard

################################################## ############################
# make sure we're running as root
#

if (( `$ID -u` != 0 )); then
$ECHO Error: must be root. Exiting... ;
exit;
fi


################################################## ############################
# check the arguments and the options
#

if [ ! -b $MOUNT_DEVICE ] ; then
$ECHO Error: $MOUNT_DEVICE ins\'t a valid device. Exiting ;
exit ;
fi

if [ ! -d $MOUNT_POINT_RW ] ; then
if [ -e $MOUNT_POINT_RW ] ; then
$ECHO Error: $MOUNT_POINT_RW isn\'t a directory. Exiting ;
exit ;
fi
$ECHO Notice: $MOUNT_POINT_RW don\'t exist. Creating... ;
mkdir -p -m 755 $MOUNT_POINT_RW ;
fi

################################################## ############################
# attempt to remount the RW mount point as RW; else abort
#

$MOUNT -o remount,rw $MOUNT_DEVICE $MOUNT_POINT_RW ;

if (( $? )); then
$ECHO Error: could not remount $MOUNT_POINT_RW readwrite ;
exit ;
fi

################################################## ############################
# continue check the arguments and the options
#

if [ ! -d $SOURCE_DIR ] ; then
$ECHO $SOURCE_DIR isn\'t a valid directory. Exiting... ;
exit ;
fi

################################################## ############################
# setting optionals settings
#

if [ -z $BACKUP_NAME ] ; then
BACKUP_NAME=BACKUP;
fi

if [ ! -z $($ECHO $BACKUP_NAME | $GREP "\/" ) ] ; then
$ECHO Error: bacup_name: $BACKUP_NAME can\'t be a subdirectory ;
exit;
fi


if [ ! -d $MOUNT_POINT_RW/$DESTINATION_DIR/ ] ; then
if [ -e $MOUNT_POINT_RW/$DESTINATION_DIR/ ] ; then
ECHO Error: $MOUNT_POINT_RW/$DESTINATION_DIR/ isn\'t a directory. Exiting ;
exit ;
fi
$ECHO Notice: $MOUNT_POINT_RW/$DESTINATION_DIR/ don\'t exist. Creating... ;
mkdir -p -m 755 $MOUNT_POINT_RW/$DESTINATION_DIR/ ;
fi


################################################## ############################
# setting optionals settings
#

if [ -z "$BACKUP_NUMBER" ] ; then
BACKUP_NUMBER=5;
fi


################################################## ############################
# rotating snapshots
# delete the oldest snapshot in background, if it exists:
#

if [ -d $MOUNT_POINT_RW/$DESTINATION_DIR/$BACKUP_NAME.$BACKUP_NUMBER ] ; then
$MV $MOUNT_POINT_RW/$DESTINATION_DIR/$BACKUP_NAME.$BACKUP_NUMBER \
$MOUNT_POINT_RW/$DESTINATION_DIR/$BACKUP_NAME.$BACKUP_NUMBER.delete
$RM -rf $MOUNT_POINT_RW/$DESTINATION_DIR/$BACKUP_NAME.$BACKUP_NUMBER.delete &
fi


################################################## ############################
# shift the middle snapshots(s) back by one, if they exist
#

for i in `$SEQ $BACKUP_NUMBER 2`; do
iminus=$(($i-1)) ;
if [ -d $MOUNT_POINT_RW/$DESTINATION_DIR/$BACKUP_NAME.$iminus ] ; then
$MV $MOUNT_POINT_RW/$DESTINATION_DIR/$BACKUP_NAME.$iminus \
$MOUNT_POINT_RW/$DESTINATION_DIR/$BACKUP_NAME.$i ;
fi
done


################################################## ############################
# make a hard-link-only (except for dirs) copy of the latest snapshot,
# if that exists
#

if [ -d $MOUNT_POINT_RW/$DESTINATION_DIR/$BACKUP_NAME.0 ] ; then
$CP -al $MOUNT_POINT_RW/$DESTINATION_DIR/$BACKUP_NAME.0 \
$MOUNT_POINT_RW/$DESTINATION_DIR/$BACKUP_NAME.1 ;
fi


################################################## ############################
# $EXCLUDE_FILE is an optional
#

if [ ! -z $EXCLUDE_FILE ] ; then
if [ -f $EXCLUDE_FILE ] ; then
EXCLUDE_LINE="--exclude-from=\"$EXCLUDE_FILE\"" ;
else
$ECHO Error: $EXCLUDE_FILE isn\'t a valid file. Exiting. ;
exit;
fi
fi

################################################## ############################
# rsync from the system into the latest snapshot (notice that
# rsync behaves like cp --remove-destination by default, so the destination
# is unlinked first. If it were not so, this would copy over the other
# snapshot(s) too!
#

$RSYNC \
-va --delete --delete-excluded \
$EXCLUDE_LINE \
$SOURCE_DIR/ $MOUNT_POINT_RW/$DESTINATION_DIR/$BACKUP_NAME.0 ;


################################################## ############################
# update the mtime of $BACKUP_NAME.0 to reflect the snapshot time
#

$TOUCH $MOUNT_POINT_RW/$DESTINATION_DIR/$BACKUP_NAME.0 ;


################################################## ############################
# wait for rm in background finish
#

wait ;

################################################## ############################
# remount the RW snapshot mountpoint as readonly
#

$MOUNT -o remount,ro $MOUNT_DEVICE $MOUNT_POINT_RW ;
if (( $? )); then
$ECHO Error: could not remount $MOUNT_POINT_RW readonly ;
exit ;
fi


#
# EOF
################################################## ############################

Hofe hat weiter geholfen
Theodor ist offline   Mit Zitat antworten
 


Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)
 

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.

Gehe zu


Alle Zeitangaben in WEZ +2. Es ist jetzt 20:45 Uhr.


Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Forum SEO by Zoints
© 2009 FSL Verlag