Improved obackup-batch.sh for crontab execution

This commit is contained in:
deajan 2015-04-26 22:28:56 +02:00
parent dfeccbdf43
commit 5b7b9b0e28
2 changed files with 23 additions and 12 deletions

View File

@ -22,6 +22,7 @@ UNDER WORK
CHANGELOG CHANGELOG
--------- ---------
- Added detection of obackup.sh script in obackup-batch.sh to overcome mising path in crontab
- Moved command line arguments after config file load for allowing command line overrides - Moved command line arguments after config file load for allowing command line overrides
- Added a config file option equivalent to --dontgetsize - Added a config file option equivalent to --dontgetsize
- Added basic install script from osync project - Added basic install script from osync project

View File

@ -3,7 +3,7 @@
PROGRAM="Obackup-batch" # Batch program to run obackup instances sequentially and rerun failed ones PROGRAM="Obackup-batch" # Batch program to run obackup instances sequentially and rerun failed ones
AUTHOR="(L) 2013-2014 by Orsiris \"Ozy\" de Jong" AUTHOR="(L) 2013-2014 by Orsiris \"Ozy\" de Jong"
CONTACT="http://www.netpower.fr/obackup - ozy@netpower.fr" CONTACT="http://www.netpower.fr/obackup - ozy@netpower.fr"
PROGRAM_BUILD=2404201501 PROGRAM_BUILD=2504201501
## Runs an obackup instance for every conf file found ## Runs an obackup instance for every conf file found
## If an instance fails, run it again if time permits ## If an instance fails, run it again if time permits
@ -17,15 +17,6 @@ MAX_EXECUTION_TIME=36000
## Specifies the number of reruns an instance may get ## Specifies the number of reruns an instance may get
MAX_RERUNS=3 MAX_RERUNS=3
## Obackup executable full path can be set here if it cannot be found on the system
if ! type -p obackup.sh > /dev/null 2>&1
then
OBACKUP_EXECUTABLE=./obackup.sh
else
OBACKUP_EXECUTABLE=$(type -p obackup.sh)
fi
## Log file path ## Log file path
if [ -w /var/log ] if [ -w /var/log ]
then then
@ -47,6 +38,25 @@ function Log
fi fi
} }
function CheckEnvironment
{
## Obackup executable full path can be set here if it cannot be found on the system
if ! type -p obackup.sh > /dev/null 2>&1
then
if [ -f /usr/local/bin/obackup.sh ]
then
OBACKUP_EXECUTABLE=/usr/local/bin/obackup.sh
elif [ -f ./obackup.sh ]
then
OBACKUP_EXECUTABLE=./obackup.sh
else
Log "Could not find obackup.sh"
exit 1
fi
else
OBACKUP_EXECUTABLE=$(type -p obackup.sh)
fi
}
function Batch function Batch
{ {
@ -77,8 +87,7 @@ function Batch
else else
RUN_AGAIN=$RUN_AGAIN" $i" RUN_AGAIN=$RUN_AGAIN" $i"
fi fi
elif [ $verbose -eq 1 ] else
then
Log "Run instance $(basename $i) succeed." Log "Run instance $(basename $i) succeed."
fi fi
done done
@ -145,5 +154,6 @@ do
esac esac
done done
CheckEnvironment
Log "$(date) Obackup batch run" Log "$(date) Obackup batch run"
Batch Batch