![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
![]() |

|
| Linux and Unix Error ! Redhat,suse,centos,mandrake,Free BSD,Sun |
![]() |
|
Need help with a small batch file
|
LinkBack | Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Administrator
Posts: 18,704
Join Date: Jan 2006
Rep Power: 10
IM:
|
Sometimes rsync fails and it produces instead of a folder named hourly.0 an empty file hourly.0 that file blocks any further processing, thus effectively stopping the sync process. this is the program part in question #!/bin/bash # ------------- system commands used by this script -------------------- ID=/usr/bin/id; ECHO=/bin/echo; MOUNT=/bin/mount; RM=/bin/rm; MV=/bin/mv; CP=/bin/cp; TOUCH=/usr/bin/touch; RSYNC=/usr/bin/rsync; # ------------- file locations ---------------------------------------- SNAPSHOT_RW=/backup/handling/snapshot/se SOURCE_DIR=/backup/smb/server1; EXCLUDES=/usr/local/etc/backup_exclude; ... # step 3: shift the first snapshots(s) back by one, if they exist, # if that exists if [ -d $SNAPSHOT_RW/hourly.0 ] ; then \ $MV $SNAPSHOT_RW/hourly.0 $SNAPSHOT_RW/hourly.1 ; \ fi; # step 4: 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 \ -a --delete --delete-excluded \ --progress \ --exclude-from="$EXCLUDES" \ --modify-window=5 \ --link-dest=$SNAPSHOT_RW/hourly.1 \ $SOURCE_DIR $SNAPSHOT_RW/hourly.0 ; I could need some help to change it this way: * In step 3 - check if instead of a folder hourly.0 a file hourly.0 exists. * If yes delete that file and procede to step 4 (+ send me a mail about the incident) * if no continue with step 3 That's all. |
|
|
|
|
|
|
|
|
#2 (permalink) |
|
Administrator
Posts: 18,704
Join Date: Jan 2006
Rep Power: 10
IM:
|
--- SENDMAIL=/usr/sbin/sendmail EMAILADDR=someaddr@example.domain ... # step 3: shift the first snapshots(s) back by one, if they exist, # if that exists if [ -f $SNAPSHOT_RW/hourly.0 ] ; then $RM -f $SNAPSHOT_RW/hourly.0 ; echo "hourly.0 file removed" | $SENDMAIL $EMAIL_ADDR fi; if [ -d $SNAPSHOT_RW/hourly.0 ] ; then \ $MV $SNAPSHOT_RW/hourly.0 $SNAPSHOT_RW/hourly.1 ; \ fi; # step 4: rsync from the system into the latest snapshot (notice that |
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|