Code cleanup continues.

This commit is contained in:
deajan 2013-07-16 23:06:58 +02:00
parent dc4c4b442a
commit aa2da27038
2 changed files with 13 additions and 22 deletions

View File

@ -1,5 +1,7 @@
## Latest changelog ## Latest changelog
- Feature freeze, version tagged as v1.84 RC1
- Code cleanup
- Uploaded first documentation - Uploaded first documentation
- Fixed an issue with RotateBackups - Fixed an issue with RotateBackups
- Updated obackup to log failed ssh command results - Updated obackup to log failed ssh command results

View File

@ -1,9 +1,9 @@
#!/bin/bash #!/bin/bash
###### Remote (or local) backup script for files & databases ###### Remote (or local) backup script for files & databases
###### (L) 2013 by Ozy de Jong (www.badministrateur.com) ###### (L) 2013 by Orsiris "Ozy" de Jong (www.netpower.fr)
OBACKUP_VERSION=1.84 OBACKUP_VERSION=1.84RC1
OBACKUP_BUILD=1107201301 OBACKUP_BUILD=1607201301
DEBUG=no DEBUG=no
SCRIPT_PID=$$ SCRIPT_PID=$$
@ -36,10 +36,6 @@ TOTAL_FILES_SIZE=0 # Total file size of $DIRECTORIES_TO_BACKUP
# /dev/shm/obackup_run_local_$SCRIPT_PID Output of command to be run localy # /dev/shm/obackup_run_local_$SCRIPT_PID Output of command to be run localy
# /dev/shm/obackup_run_remote_$SCRIPT_PID Output of command to be run remotely # /dev/shm/obackup_run_remote_$SCRIPT_PID Output of command to be run remotely
# Alert flags
soft_alert_total=0
error_alert=0
function Log function Log
{ {
echo "TIME: $SECONDS - $1" >> "$LOG_FILE" echo "TIME: $SECONDS - $1" >> "$LOG_FILE"
@ -68,7 +64,7 @@ function TrapError
function TrapStop function TrapStop
{ {
LogError " /!\ WARNING: Manual extit of backup script. Backups may be in inconsistent state." LogError " /!\ WARNING: Manual exit of backup script. Backups may be in inconsistent state."
if [ "$DEBUG" == "no" ] if [ "$DEBUG" == "no" ]
then then
CleanUp CleanUp
@ -632,8 +628,6 @@ function BackupDatabases
WaitForTaskCompletition $child_pid $SOFT_MAX_EXEC_TIME_DB_TASK $HARD_MAX_EXEC_TIME_DB_TASK WaitForTaskCompletition $child_pid $SOFT_MAX_EXEC_TIME_DB_TASK $HARD_MAX_EXEC_TIME_DB_TASK
wait $child_pid wait $child_pid
retval=$? retval=$?
SECONDS_END=$SECONDS
EXEC_TIME=$(($SECONDS_END - $SECONDS_BEGIN))
if [ $retval -ne 0 ] if [ $retval -ne 0 ]
then then
LogError "Backup failed." LogError "Backup failed."
@ -852,8 +846,6 @@ function FilesBackup
WaitForTaskCompletition $child_pid $SOFT_MAX_EXEC_TIME_FILE_TASK $HARD_MAX_EXEC_TIME_FILE_TASK WaitForTaskCompletition $child_pid $SOFT_MAX_EXEC_TIME_FILE_TASK $HARD_MAX_EXEC_TIME_FILE_TASK
wait $child_pid wait $child_pid
retval=$? retval=$?
SECONDS_END=$SECONDS
EXEC_TIME=$(($SECONDS_END-$SECONDS_BEGIN))
if [ $retval -ne 0 ] if [ $retval -ne 0 ]
then then
LogError "Backup failed on remote files." LogError "Backup failed on remote files."
@ -877,8 +869,6 @@ function FilesBackup
WaitForTaskCompletition $child_pid $SOFT_MAX_EXEC_TIME_FILE_TASK $HARD_MAX_EXEC_TIME_FILE_TASK WaitForTaskCompletition $child_pid $SOFT_MAX_EXEC_TIME_FILE_TASK $HARD_MAX_EXEC_TIME_FILE_TASK
wait $child_pid wait $child_pid
retval=$? retval=$?
SECONDS_END=$SECONDS
EXEC_TIME=$(($SECONDS_END-$SECONDS_BEGIN))
if [ $retval -ne 0 ] if [ $retval -ne 0 ]
then then
LogError "Backup failed on remote files." LogError "Backup failed on remote files."
@ -1024,11 +1014,13 @@ function Usage
# Command line argument flags # Command line argument flags
dryrun=0 dryrun=0
silent=0 silent=0
# Alert flags
soft_alert_total=0
error_alert=0
if [ $# -eq 0 ] if [ $# -eq 0 ]
then then
Usage Usage
exit
fi fi
for i in "$@" for i in "$@"
@ -1042,7 +1034,6 @@ do
;; ;;
--help|-h) --help|-h)
Usage Usage
exit
;; ;;
esac esac
done done
@ -1071,12 +1062,6 @@ then
RunAfterHook RunAfterHook
fi fi
CleanUp CleanUp
if [ $error_alert -ne 0 ]
then
exit 1
else
exit 0
fi
else else
LogError "Configuration file could not be loaded." LogError "Configuration file could not be loaded."
exit 1 exit 1
@ -1085,12 +1070,16 @@ then
LogError "No configuration file provided." LogError "No configuration file provided."
exit 1 exit 1
fi fi
else
LogError "Environment not suitable to run obackup."
fi fi
if [ $error_alert -ne 0 ] if [ $error_alert -ne 0 ]
then then
SendAlert SendAlert
LogError "Backup script finished with errors." LogError "Backup script finished with errors."
exit 1
else else
Log "Backup script finshed." Log "Backup script finshed."
exit 0
fi fi