1
0
mirror of https://github.com/deajan/obackup.git synced 2024-11-15 04:03:41 +01:00

Changed default yes/no to booleans

This commit is contained in:
deajan 2019-02-08 13:22:37 +01:00
parent 3fccc45ac7
commit 0f18258e61
3 changed files with 168 additions and 154 deletions

View File

@ -8,7 +8,7 @@ AUTHOR="(C) 2013-2019 by Orsiris de Jong"
CONTACT="http://www.netpower.fr/obackup - ozy@netpower.fr" CONTACT="http://www.netpower.fr/obackup - ozy@netpower.fr"
PROGRAM_VERSION=2.1-RC1 PROGRAM_VERSION=2.1-RC1
PROGRAM_BUILD=2018110602 PROGRAM_BUILD=2018110602
IS_STABLE=yes IS_STABLE=true
#### Execution order #__WITH_PARANOIA_DEBUG #### Execution order #__WITH_PARANOIA_DEBUG
# GetLocalOS #__WITH_PARANOIA_DEBUG # GetLocalOS #__WITH_PARANOIA_DEBUG
@ -79,14 +79,14 @@ function TrapQuit {
fi fi
if [ $ERROR_ALERT == true ]; then if [ $ERROR_ALERT == true ]; then
if [ "$RUN_AFTER_CMD_ON_ERROR" == "yes" ]; then if [ "$RUN_AFTER_CMD_ON_ERROR" == true ]; then
RunAfterHook RunAfterHook
fi fi
Logger "$PROGRAM finished with errors." "ERROR" Logger "$PROGRAM finished with errors." "ERROR"
SendAlert SendAlert
exitcode=1 exitcode=1
elif [ $WARN_ALERT == true ]; then elif [ $WARN_ALERT == true ]; then
if [ "$RUN_AFTER_CMD_ON_ERROR" == "yes" ]; then if [ "$RUN_AFTER_CMD_ON_ERROR" == true ]; then
RunAfterHook RunAfterHook
fi fi
Logger "$PROGRAM finished with warnings." "WARN" Logger "$PROGRAM finished with warnings." "WARN"
@ -110,7 +110,7 @@ function TrapQuit {
function CheckEnvironment { function CheckEnvironment {
__CheckArguments 0 $# "$@" #__WITH_PARANOIA_DEBUG __CheckArguments 0 $# "$@" #__WITH_PARANOIA_DEBUG
if [ "$REMOTE_OPERATION" == "yes" ]; then if [ "$REMOTE_OPERATION" == true ]; then
if ! type ssh > /dev/null 2>&1 ; then if ! type ssh > /dev/null 2>&1 ; then
Logger "ssh not present. Cannot start backup." "CRITICAL" Logger "ssh not present. Cannot start backup." "CRITICAL"
exit 1 exit 1
@ -121,7 +121,7 @@ function CheckEnvironment {
exit 1 exit 1
fi fi
else else
if [ "$SQL_BACKUP" != "no" ]; then if [ "$SQL_BACKUP" != false ]; then
if ! type mysqldump > /dev/null 2>&1 ; then if ! type mysqldump > /dev/null 2>&1 ; then
Logger "mysqldump not present. Cannot backup SQL." "CRITICAL" Logger "mysqldump not present. Cannot backup SQL." "CRITICAL"
CAN_BACKUP_SQL=false CAN_BACKUP_SQL=false
@ -133,14 +133,14 @@ function CheckEnvironment {
fi fi
fi fi
if [ "$FILE_BACKUP" != "no" ]; then if [ "$FILE_BACKUP" != false ]; then
if ! type rsync > /dev/null 2>&1 ; then if ! type rsync > /dev/null 2>&1 ; then
Logger "rsync not present. Cannot backup files." "CRITICAL" Logger "rsync not present. Cannot backup files." "CRITICAL"
CAN_BACKUP_FILES=false CAN_BACKUP_FILES=false
fi fi
fi fi
if [ "$ENCRYPTION" == "yes" ]; then if [ "$ENCRYPTION" == true ]; then
CheckCryptEnvironnment CheckCryptEnvironnment
fi fi
@ -167,15 +167,20 @@ function CheckCryptEnvironnment {
function CheckCurrentConfig { function CheckCurrentConfig {
__CheckArguments 0 $# "$@" #__WITH_PARANOIA_DEBUG __CheckArguments 0 $# "$@" #__WITH_PARANOIA_DEBUG
local test
local booleans
local num_vars
if [ "$INSTANCE_ID" == "" ]; then if [ "$INSTANCE_ID" == "" ]; then
Logger "No INSTANCE_ID defined in config file." "CRITICAL" Logger "No INSTANCE_ID defined in config file." "CRITICAL"
exit 1 exit 1
fi fi
# Check all variables that should contain "yes" or "no" # v2 config will use true / false instead of yes / no
declare -a yes_no_vars=(SQL_BACKUP FILE_BACKUP ENCRYPTION CREATE_DIRS KEEP_ABSOLUTE_PATHS GET_BACKUP_SIZE SSH_COMPRESSION SSH_IGNORE_KNOWN_HOSTS REMOTE_HOST_PING SUDO_EXEC DATABASES_ALL PRESERVE_PERMISSIONS PRESERVE_OWNER PRESERVE_GROUP PRESERVE_EXECUTABILITY PRESERVE_ACL PRESERVE_XATTR COPY_SYMLINKS KEEP_DIRLINKS PRESERVE_HARDLINKS RSYNC_COMPRESS PARTIAL DELETE_VANISHED_FILES DELTA_COPIES ROTATE_SQL_BACKUPS ROTATE_FILE_BACKUPS STOP_ON_CMD_ERROR RUN_AFTER_CMD_ON_ERROR) # Check all variables that should contain "yes" or "no", true or false
for i in "${yes_no_vars[@]}"; do declare -a booleans=(SQL_BACKUP FILE_BACKUP ENCRYPTION CREATE_DIRS KEEP_ABSOLUTE_PATHS GET_BACKUP_SIZE SSH_COMPRESSION SSH_IGNORE_KNOWN_HOSTS REMOTE_HOST_PING SUDO_EXEC DATABASES_ALL PRESERVE_PERMISSIONS PRESERVE_OWNER PRESERVE_GROUP PRESERVE_EXECUTABILITY PRESERVE_ACL PRESERVE_XATTR COPY_SYMLINKS KEEP_DIRLINKS PRESERVE_HARDLINKS RSYNC_COMPRESS PARTIAL DELETE_VANISHED_FILES DELTA_COPIES ROTATE_SQL_BACKUPS ROTATE_FILE_BACKUPS STOP_ON_CMD_ERROR RUN_AFTER_CMD_ON_ERROR)
test="if [ \"\$$i\" != \"yes\" ] && [ \"\$$i\" != \"no\" ]; then Logger \"Bogus $i value [\$$i] defined in config file. Correct your config file or update it with the update script if using and old version.\" \"CRITICAL\"; exit 1; fi" for i in "${booleans[@]}"; do
test="if [ \"\$$i\" != \"yes\" ] && [ \"\$$i\" != \"no\" ] && [ \"\$$i\" != true ] && [ \"\$$i\" != false ]; then Logger \"Bogus $i value [\$$i] defined in config file. Correct your config file or update it with the update script if using and old version.\" \"CRITICAL\"; exit 1; fi"
eval "$test" eval "$test"
done done
@ -191,14 +196,14 @@ function CheckCurrentConfig {
eval "$test" eval "$test"
done done
if [ "$FILE_BACKUP" == "yes" ]; then if [ "$FILE_BACKUP" == true ]; then
if [ "$DIRECTORY_LIST" == "" ] && [ "$RECURSIVE_DIRECTORY_LIST" == "" ]; then if [ "$DIRECTORY_LIST" == "" ] && [ "$RECURSIVE_DIRECTORY_LIST" == "" ]; then
Logger "No directories specified in config file, no files to backup." "ERROR" Logger "No directories specified in config file, no files to backup." "ERROR"
CAN_BACKUP_FILES=false CAN_BACKUP_FILES=false
fi fi
fi fi
if [ "$REMOTE_OPERATION" == "yes" ] && [ ! -f "$SSH_RSA_PRIVATE_KEY" ]; then if [ "$REMOTE_OPERATION" == true ] && [ ! -f "$SSH_RSA_PRIVATE_KEY" ]; then
Logger "Cannot find rsa private key [$SSH_RSA_PRIVATE_KEY]. Cannot connect to remote system." "CRITICAL" Logger "Cannot find rsa private key [$SSH_RSA_PRIVATE_KEY]. Cannot connect to remote system." "CRITICAL"
exit 1 exit 1
fi fi
@ -209,17 +214,17 @@ function CheckCurrentConfig {
# exit 1 # exit 1
#fi #fi
if [ "$SQL_BACKUP" == "yes" ] && [ "$SQL_STORAGE" == "" ]; then if [ "$SQL_BACKUP" == true ] && [ "$SQL_STORAGE" == "" ]; then
Logger "SQL_STORAGE not defined." "CRITICAL" Logger "SQL_STORAGE not defined." "CRITICAL"
exit 1 exit 1
fi fi
if [ "$FILE_BACKUP" == "yes" ] && [ "$FILE_STORAGE" == "" ]; then if [ "$FILE_BACKUP" == true ] && [ "$FILE_STORAGE" == "" ]; then
Logger "FILE_STORAGE not defined." "CRITICAL" Logger "FILE_STORAGE not defined." "CRITICAL"
exit 1 exit 1
fi fi
if [ "$ENCRYPTION" == "yes" ]; then if [ "$ENCRYPTION" == true ]; then
if [ "$CRYPT_STORAGE" == "" ]; then if [ "$CRYPT_STORAGE" == "" ]; then
Logger "CRYPT_STORAGE not defined." "CRITICAL" Logger "CRYPT_STORAGE not defined." "CRITICAL"
exit 1 exit 1
@ -230,12 +235,25 @@ function CheckCurrentConfig {
fi fi
fi fi
if [ "$REMOTE_OPERATION" == "yes" ] && ([ ! -f "$SSH_RSA_PRIVATE_KEY" ] && [ ! -f "$SSH_PASSWORD_FILE" ]); then if [ "$REMOTE_OPERATION" == true ] && ([ ! -f "$SSH_RSA_PRIVATE_KEY" ] && [ ! -f "$SSH_PASSWORD_FILE" ]); then
Logger "Cannot find rsa private key [$SSH_RSA_PRIVATE_KEY] nor password file [$SSH_PASSWORD_FILE]. No authentication method provided." "CRITICAL" Logger "Cannot find rsa private key [$SSH_RSA_PRIVATE_KEY] nor password file [$SSH_PASSWORD_FILE]. No authentication method provided." "CRITICAL"
exit 1 exit 1
fi fi
} }
# Change all booleans with "yes" or "no" to true / false for v2 config syntax compatibility
function UpdateBooleans {
local update
local booleans
declare -a booleans=(SQL_BACKUP FILE_BACKUP ENCRYPTION CREATE_DIRS KEEP_ABSOLUTE_PATHS GET_BACKUP_SIZE SSH_COMPRESSION SSH_IGNORE_KNOWN_HOSTS REMOTE_HOST_PING SUDO_EXEC DATABASES_ALL PRESERVE_PERMISSIONS PRESERVE_OWNER PRESERVE_GROUP PRESERVE_EXECUTABILITY PRESERVE_ACL PRESERVE_XATTR COPY_SYMLINKS KEEP_DIRLINKS PRESERVE_HARDLINKS RSYNC_COMPRESS PARTIAL DELETE_VANISHED_FILES DELTA_COPIES ROTATE_SQL_BACKUPS ROTATE_FILE_BACKUPS STOP_ON_CMD_ERROR RUN_AFTER_CMD_ON_ERROR)
for i in "${booleans[@]}"; do
update="if [ \"\$$i\" == \"yes\" ]; then $i=true; fi; if [ \"\$$i\" == \"no\" ]; then $i=false; fi"
eval "$update"
done
}
function CheckRunningInstances { function CheckRunningInstances {
__CheckArguments 0 $# "$@" #__WITH_PARANOIA_DEBUG __CheckArguments 0 $# "$@" #__WITH_PARANOIA_DEBUG
@ -337,7 +355,7 @@ function ListDatabases {
while read -r line; do while read -r line; do
while read -r name size; do dbName=$name; dbSize=$size; done <<< "$line" while read -r name size; do dbName=$name; dbSize=$size; done <<< "$line"
if [ "$DATABASES_ALL" == "yes" ]; then if [ "$DATABASES_ALL" == true ]; then
dbBackup=true dbBackup=true
IFS=$PATH_SEPARATOR_CHAR read -r -a dbArray <<< "$DATABASES_ALL_EXCLUDE_LIST" IFS=$PATH_SEPARATOR_CHAR read -r -a dbArray <<< "$DATABASES_ALL_EXCLUDE_LIST"
for j in "${dbArray[@]}"; do for j in "${dbArray[@]}"; do
@ -659,11 +677,11 @@ function GetDirectoriesSize {
Logger "Getting files size" "NOTICE" Logger "Getting files size" "NOTICE"
if [ "$BACKUP_TYPE" == "local" ] || [ "$BACKUP_TYPE" == "push" ]; then if [ "$BACKUP_TYPE" == "local" ] || [ "$BACKUP_TYPE" == "push" ]; then
if [ "$FILE_BACKUP" != "no" ]; then if [ "$FILE_BACKUP" != false ]; then
_GetDirectoriesSizeLocal "$FILE_SIZE_LIST" _GetDirectoriesSizeLocal "$FILE_SIZE_LIST"
fi fi
elif [ "$BACKUP_TYPE" == "pull" ]; then elif [ "$BACKUP_TYPE" == "pull" ]; then
if [ "$FILE_BACKUP" != "no" ]; then if [ "$FILE_BACKUP" != false ]; then
_GetDirectoriesSizeRemote "$FILE_SIZE_LIST" _GetDirectoriesSizeRemote "$FILE_SIZE_LIST"
fi fi
fi fi
@ -731,38 +749,38 @@ function CreateStorageDirectories {
__CheckArguments 0 $# "$@" #__WITH_PARANOIA_DEBUG __CheckArguments 0 $# "$@" #__WITH_PARANOIA_DEBUG
if [ "$BACKUP_TYPE" == "local" ] || [ "$BACKUP_TYPE" == "pull" ]; then if [ "$BACKUP_TYPE" == "local" ] || [ "$BACKUP_TYPE" == "pull" ]; then
if [ "$SQL_BACKUP" != "no" ]; then if [ "$SQL_BACKUP" != false ]; then
_CreateDirectoryLocal "$SQL_STORAGE" _CreateDirectoryLocal "$SQL_STORAGE"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
CAN_BACKUP_SQL=false CAN_BACKUP_SQL=false
fi fi
fi fi
if [ "$FILE_BACKUP" != "no" ]; then if [ "$FILE_BACKUP" != false ]; then
_CreateDirectoryLocal "$FILE_STORAGE" _CreateDirectoryLocal "$FILE_STORAGE"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
CAN_BACKUP_FILES=false CAN_BACKUP_FILES=false
fi fi
fi fi
if [ "$ENCRYPTION" == "yes" ]; then if [ "$ENCRYPTION" == true ]; then
_CreateDirectoryLocal "$CRYPT_STORAGE" _CreateDirectoryLocal "$CRYPT_STORAGE"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
CAN_BACKUP_FILES=false CAN_BACKUP_FILES=false
fi fi
fi fi
elif [ "$BACKUP_TYPE" == "push" ]; then elif [ "$BACKUP_TYPE" == "push" ]; then
if [ "$SQL_BACKUP" != "no" ]; then if [ "$SQL_BACKUP" != false ]; then
_CreateDirectoryRemote "$SQL_STORAGE" _CreateDirectoryRemote "$SQL_STORAGE"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
CAN_BACKUP_SQL=false CAN_BACKUP_SQL=false
fi fi
fi fi
if [ "$FILE_BACKUP" != "no" ]; then if [ "$FILE_BACKUP" != false ]; then
_CreateDirectoryRemote "$FILE_STORAGE" _CreateDirectoryRemote "$FILE_STORAGE"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
CAN_BACKUP_FILES=false CAN_BACKUP_FILES=false
fi fi
fi fi
if [ "$ENCRYPTION" == "yes" ]; then if [ "$ENCRYPTION" == true ]; then
_CreateDirectoryLocal "$CRYPT_STORAGE" _CreateDirectoryLocal "$CRYPT_STORAGE"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
CAN_BACKUP_FILES=false CAN_BACKUP_FILES=false
@ -866,7 +884,7 @@ function CheckDiskSpace {
__CheckArguments 0 $# "$@" #__WITH_PARANOIA_DEBUG __CheckArguments 0 $# "$@" #__WITH_PARANOIA_DEBUG
if [ "$BACKUP_TYPE" == "local" ] || [ "$BACKUP_TYPE" == "pull" ]; then if [ "$BACKUP_TYPE" == "local" ] || [ "$BACKUP_TYPE" == "pull" ]; then
if [ "$SQL_BACKUP" != "no" ]; then if [ "$SQL_BACKUP" != false ]; then
GetDiskSpaceLocal "$SQL_STORAGE" GetDiskSpaceLocal "$SQL_STORAGE"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
SQL_DISK_SPACE=0 SQL_DISK_SPACE=0
@ -876,7 +894,7 @@ function CheckDiskSpace {
SQL_DRIVE=$DRIVE SQL_DRIVE=$DRIVE
fi fi
fi fi
if [ "$FILE_BACKUP" != "no" ]; then if [ "$FILE_BACKUP" != false ]; then
GetDiskSpaceLocal "$FILE_STORAGE" GetDiskSpaceLocal "$FILE_STORAGE"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
FILE_DISK_SPACE=0 FILE_DISK_SPACE=0
@ -886,7 +904,7 @@ function CheckDiskSpace {
FILE_DRIVE=$DRIVE FILE_DRIVE=$DRIVE
fi fi
fi fi
if [ "$ENCRYPTION" != "no" ]; then if [ "$ENCRYPTION" != false ]; then
GetDiskSpaceLocal "$CRYPT_STORAGE" GetDiskSpaceLocal "$CRYPT_STORAGE"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
CRYPT_DISK_SPACE=0 CRYPT_DISK_SPACE=0
@ -898,7 +916,7 @@ function CheckDiskSpace {
fi fi
fi fi
elif [ "$BACKUP_TYPE" == "push" ]; then elif [ "$BACKUP_TYPE" == "push" ]; then
if [ "$SQL_BACKUP" != "no" ]; then if [ "$SQL_BACKUP" != false ]; then
GetDiskSpaceRemote "$SQL_STORAGE" GetDiskSpaceRemote "$SQL_STORAGE"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
SQL_DISK_SPACE=0 SQL_DISK_SPACE=0
@ -907,7 +925,7 @@ function CheckDiskSpace {
SQL_DRIVE=$DRIVE SQL_DRIVE=$DRIVE
fi fi
fi fi
if [ "$FILE_BACKUP" != "no" ]; then if [ "$FILE_BACKUP" != false ]; then
GetDiskSpaceRemote "$FILE_STORAGE" GetDiskSpaceRemote "$FILE_STORAGE"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
FILE_DISK_SPACE=0 FILE_DISK_SPACE=0
@ -916,7 +934,7 @@ function CheckDiskSpace {
FILE_DRIVE=$DRIVE FILE_DRIVE=$DRIVE
fi fi
fi fi
if [ "$ENCRYPTION" != "no" ]; then if [ "$ENCRYPTION" != false ]; then
GetDiskSpaceLocal "$CRYPT_STORAGE" GetDiskSpaceLocal "$CRYPT_STORAGE"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
CRYPT_DISK_SPACE=0 CRYPT_DISK_SPACE=0
@ -937,7 +955,7 @@ function CheckDiskSpace {
TOTAL_FILES_SIZE=-1 TOTAL_FILES_SIZE=-1
fi fi
if [ "$SQL_BACKUP" != "no" ] && [ $CAN_BACKUP_SQL == true ]; then if [ "$SQL_BACKUP" != false ] && [ $CAN_BACKUP_SQL == true ]; then
if [ $SQL_DISK_SPACE -eq 0 ]; then if [ $SQL_DISK_SPACE -eq 0 ]; then
Logger "Storage space in [$SQL_STORAGE] reported to be 0Ko." "WARN" Logger "Storage space in [$SQL_STORAGE] reported to be 0Ko." "WARN"
fi fi
@ -950,7 +968,7 @@ function CheckDiskSpace {
Logger "SQL storage Space: $SQL_DISK_SPACE Ko - Databases size: $TOTAL_DATABASES_SIZE Ko" "NOTICE" Logger "SQL storage Space: $SQL_DISK_SPACE Ko - Databases size: $TOTAL_DATABASES_SIZE Ko" "NOTICE"
fi fi
if [ "$FILE_BACKUP" != "no" ] && [ $CAN_BACKUP_FILES == true ]; then if [ "$FILE_BACKUP" != false ] && [ $CAN_BACKUP_FILES == true ]; then
if [ $FILE_DISK_SPACE -eq 0 ]; then if [ $FILE_DISK_SPACE -eq 0 ]; then
Logger "Storage space in [$FILE_STORAGE] reported to be 0 Ko." "WARN" Logger "Storage space in [$FILE_STORAGE] reported to be 0 Ko." "WARN"
fi fi
@ -963,8 +981,8 @@ function CheckDiskSpace {
Logger "File storage space: $FILE_DISK_SPACE Ko - Files size: $TOTAL_FILES_SIZE Ko" "NOTICE" Logger "File storage space: $FILE_DISK_SPACE Ko - Files size: $TOTAL_FILES_SIZE Ko" "NOTICE"
fi fi
if [ "$ENCRYPTION" == "yes" ]; then if [ "$ENCRYPTION" == true ]; then
if [ "$SQL_BACKUP" != "no" ]; then if [ "$SQL_BACKUP" != false ]; then
if [ "$SQL_DRIVE" == "$CRYPT_DRIVE" ]; then if [ "$SQL_DRIVE" == "$CRYPT_DRIVE" ]; then
if [ $((SQL_DISK_SPACE/2)) -lt $((TOTAL_DATABASES_SIZE)) ]; then if [ $((SQL_DISK_SPACE/2)) -lt $((TOTAL_DATABASES_SIZE)) ]; then
Logger "Disk space in [$SQL_STORAGE] and [$CRYPT_STORAGE] may be insufficient to backup SQL ($SQL_DISK_SPACE Ko available in $SQL_DRIVE) (non compressed databases calculation + crypt storage space)." "WARN" Logger "Disk space in [$SQL_STORAGE] and [$CRYPT_STORAGE] may be insufficient to backup SQL ($SQL_DISK_SPACE Ko available in $SQL_DRIVE) (non compressed databases calculation + crypt storage space)." "WARN"
@ -976,7 +994,7 @@ function CheckDiskSpace {
fi fi
fi fi
if [ "$FILE_BACKUP" != "no" ]; then if [ "$FILE_BACKUP" != false ]; then
if [ "$FILE_DRIVE" == "$CRYPT_DRIVE" ]; then if [ "$FILE_DRIVE" == "$CRYPT_DRIVE" ]; then
if [ $((FILE_DISK_SPACE/2)) -lt $((TOTAL_FILES_SIZE)) ]; then if [ $((FILE_DISK_SPACE/2)) -lt $((TOTAL_FILES_SIZE)) ]; then
Logger "Disk space in [$FILE_STORAGE] and [$CRYPT_STORAGE] may be insufficient to encrypt Sfiles ($FILE_DISK_SPACE Ko available in $FILE_DRIVE)." "WARN" Logger "Disk space in [$FILE_STORAGE] and [$CRYPT_STORAGE] may be insufficient to encrypt Sfiles ($FILE_DISK_SPACE Ko available in $FILE_DRIVE)." "WARN"
@ -991,7 +1009,7 @@ function CheckDiskSpace {
Logger "Crypt storage space: $CRYPT_DISK_SPACE Ko" "NOTICE" Logger "Crypt storage space: $CRYPT_DISK_SPACE Ko" "NOTICE"
fi fi
if [ $BACKUP_SIZE_MINIMUM -gt $((TOTAL_DATABASES_SIZE+TOTAL_FILES_SIZE)) ] && [ "$GET_BACKUP_SIZE" != "no" ]; then if [ $BACKUP_SIZE_MINIMUM -gt $((TOTAL_DATABASES_SIZE+TOTAL_FILES_SIZE)) ] && [ "$GET_BACKUP_SIZE" != false ]; then
Logger "Backup size is smaller than expected." "WARN" Logger "Backup size is smaller than expected." "WARN"
fi fi
} }
@ -1152,7 +1170,7 @@ function BackupDatabase {
mysqlOptions="$MYSQLDUMP_OPTIONS" mysqlOptions="$MYSQLDUMP_OPTIONS"
fi fi
if [ "$ENCRYPTION" == "yes" ]; then if [ "$ENCRYPTION" == true ]; then
encrypt=true encrypt=true
Logger "Backing up encrypted database [$database]." "NOTICE" Logger "Backing up encrypted database [$database]." "NOTICE"
else else
@ -1461,7 +1479,7 @@ function FilesBackup {
for backupTask in "${backupTasks[@]}"; do for backupTask in "${backupTasks[@]}"; do
# Backup directories from simple list # Backup directories from simple list
if [ "$KEEP_ABSOLUTE_PATHS" != "no" ]; then if [ "$KEEP_ABSOLUTE_PATHS" != false ]; then
# Fix for backup of '/' # Fix for backup of '/'
if [ "${backupTask#/}/" == "/" ]; then if [ "${backupTask#/}/" == "/" ]; then
destinationDir="$FILE_STORAGE/" destinationDir="$FILE_STORAGE/"
@ -1475,14 +1493,14 @@ function FilesBackup {
fi fi
Logger "Beginning file backup of [$backupTask] to [$destinationDir] as $BACKUP_TYPE backup." "NOTICE" Logger "Beginning file backup of [$backupTask] to [$destinationDir] as $BACKUP_TYPE backup." "NOTICE"
if [ "$ENCRYPTION" == "yes" ] && ([ "$BACKUP_TYPE" == "local" ] || [ "$BACKUP_TYPE" == "push" ]); then if [ "$ENCRYPTION" == true ] && ([ "$BACKUP_TYPE" == "local" ] || [ "$BACKUP_TYPE" == "push" ]); then
EncryptFiles "$backupTask" "$CRYPT_STORAGE" "$GPG_RECIPIENT" true true EncryptFiles "$backupTask" "$CRYPT_STORAGE" "$GPG_RECIPIENT" true true
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
Rsync "$CRYPT_STORAGE/$backupTask" "$destinationDir" true Rsync "$CRYPT_STORAGE/$backupTask" "$destinationDir" true
else else
Logger "backup failed." "ERROR" Logger "backup failed." "ERROR"
fi fi
elif [ "$ENCRYPTION" == "yes" ] && [ "$BACKUP_TYPE" == "pull" ]; then elif [ "$ENCRYPTION" == true ] && [ "$BACKUP_TYPE" == "pull" ]; then
Rsync "$backupTask" "$destinationDir" true Rsync "$backupTask" "$destinationDir" true
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
EncryptFiles "$encryptDir" "$CRYPT_STORAGE/$backupTask" "$GPG_RECIPIENT" true false EncryptFiles "$encryptDir" "$CRYPT_STORAGE/$backupTask" "$GPG_RECIPIENT" true false
@ -1497,7 +1515,7 @@ function FilesBackup {
for backupTask in "${backupTasks[@]}"; do for backupTask in "${backupTasks[@]}"; do
# Backup recursive directories without recursion # Backup recursive directories without recursion
if [ "$KEEP_ABSOLUTE_PATHS" != "no" ]; then if [ "$KEEP_ABSOLUTE_PATHS" != false ]; then
# Fix for backup of '/' # Fix for backup of '/'
if [ "${backupTask#/}/" == "/" ]; then if [ "${backupTask#/}/" == "/" ]; then
destinationDir="$FILE_STORAGE/" destinationDir="$FILE_STORAGE/"
@ -1511,14 +1529,14 @@ function FilesBackup {
fi fi
Logger "Beginning non recursive file backup of [$backupTask] to [$destinationDir] as $BACKUP_TYPE backup." "NOTICE" Logger "Beginning non recursive file backup of [$backupTask] to [$destinationDir] as $BACKUP_TYPE backup." "NOTICE"
if [ "$ENCRYPTION" == "yes" ] && ([ "$BACKUP_TYPE" == "local" ] || [ "$BACKUP_TYPE" == "push" ]); then if [ "$ENCRYPTION" == true ] && ([ "$BACKUP_TYPE" == "local" ] || [ "$BACKUP_TYPE" == "push" ]); then
EncryptFiles "$backupTask" "$CRYPT_STORAGE" "$GPG_RECIPIENT" false true EncryptFiles "$backupTask" "$CRYPT_STORAGE" "$GPG_RECIPIENT" false true
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
Rsync "$CRYPT_STORAGE/$backupTask" "$destinationDir" false Rsync "$CRYPT_STORAGE/$backupTask" "$destinationDir" false
else else
Logger "backup failed." "ERROR" Logger "backup failed." "ERROR"
fi fi
elif [ "$ENCRYPTION" == "yes" ] && [ "$BACKUP_TYPE" == "pull" ]; then elif [ "$ENCRYPTION" == true ] && [ "$BACKUP_TYPE" == "pull" ]; then
Rsync "$backupTask" "$destinationDir" false Rsync "$backupTask" "$destinationDir" false
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
EncryptFiles "$encryptDir" "$CRYPT_STORAGE/$backupTask" "$GPG_RECIPIENT" false false EncryptFiles "$encryptDir" "$CRYPT_STORAGE/$backupTask" "$GPG_RECIPIENT" false false
@ -1533,7 +1551,7 @@ function FilesBackup {
for backupTask in "${backupTasks[@]}"; do for backupTask in "${backupTasks[@]}"; do
# Backup sub directories of recursive directories # Backup sub directories of recursive directories
if [ "$KEEP_ABSOLUTE_PATHS" != "no" ]; then if [ "$KEEP_ABSOLUTE_PATHS" != false ]; then
# Fix for backup of '/' # Fix for backup of '/'
if [ "${backupTask#/}/" == "/" ]; then if [ "${backupTask#/}/" == "/" ]; then
destinationDir="$FILE_STORAGE/" destinationDir="$FILE_STORAGE/"
@ -1547,14 +1565,14 @@ function FilesBackup {
fi fi
Logger "Beginning recursive child file backup of [$backupTask] to [$destinationDir] as $BACKUP_TYPE backup." "NOTICE" Logger "Beginning recursive child file backup of [$backupTask] to [$destinationDir] as $BACKUP_TYPE backup." "NOTICE"
if [ "$ENCRYPTION" == "yes" ] && ([ "$BACKUP_TYPE" == "local" ] || [ "$BACKUP_TYPE" == "push" ]); then if [ "$ENCRYPTION" == true ] && ([ "$BACKUP_TYPE" == "local" ] || [ "$BACKUP_TYPE" == "push" ]); then
EncryptFiles "$backupTask" "$CRYPT_STORAGE" "$GPG_RECIPIENT" true true EncryptFiles "$backupTask" "$CRYPT_STORAGE" "$GPG_RECIPIENT" true true
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
Rsync "$CRYPT_STORAGE/$backupTask" "$destinationDir" true Rsync "$CRYPT_STORAGE/$backupTask" "$destinationDir" true
else else
Logger "backup failed." "ERROR" Logger "backup failed." "ERROR"
fi fi
elif [ "$ENCRYPTION" == "yes" ] && [ "$BACKUP_TYPE" == "pull" ]; then elif [ "$ENCRYPTION" == true ] && [ "$BACKUP_TYPE" == "pull" ]; then
Rsync "$backupTask" "$destinationDir" true Rsync "$backupTask" "$destinationDir" true
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
EncryptFiles "$encryptDir" "$CRYPT_STORAGE/$backupTask" "$GPG_RECIPIENT" true false EncryptFiles "$encryptDir" "$CRYPT_STORAGE/$backupTask" "$GPG_RECIPIENT" true false
@ -1637,7 +1655,7 @@ function _RotateBackupsLocal {
fi fi
else else
#elif [ "$REMOTE_OPERATION" == "yes" ]; then #elif [ "$REMOTE_OPERATION" == true ]; then
cmd="cp -R \"$backup\" \"$backup.$PROGRAM.1\"" cmd="cp -R \"$backup\" \"$backup.$PROGRAM.1\""
Logger "Launching command [$cmd]." "DEBUG" Logger "Launching command [$cmd]." "DEBUG"
eval "$cmd" & eval "$cmd" &
@ -1720,7 +1738,7 @@ function _RotateBackupsRemoteSSH {
fi fi
else else
#elif [ "$REMOTE_OPERATION" == "yes" ]; then #elif [ "$REMOTE_OPERATION" == true ]; then
cmd="cp -R \"$backup\" \"$backup.$PROGRAM.1\"" cmd="cp -R \"$backup\" \"$backup.$PROGRAM.1\""
RemoteLogger "Launching command [$cmd]." "DEBUG" RemoteLogger "Launching command [$cmd]." "DEBUG"
eval "$cmd" eval "$cmd"
@ -1782,7 +1800,7 @@ function Init {
## Test if target dir is a ssh uri, and if yes, break it down it its values ## Test if target dir is a ssh uri, and if yes, break it down it its values
if [ "${REMOTE_SYSTEM_URI:0:6}" == "ssh://" ] && [ "$BACKUP_TYPE" != "local" ]; then if [ "${REMOTE_SYSTEM_URI:0:6}" == "ssh://" ] && [ "$BACKUP_TYPE" != "local" ]; then
REMOTE_OPERATION="yes" REMOTE_OPERATION=true
# remove leadng 'ssh://' # remove leadng 'ssh://'
uri=${REMOTE_SYSTEM_URI#ssh://*} uri=${REMOTE_SYSTEM_URI#ssh://*}
@ -1819,7 +1837,7 @@ function Init {
RSYNC_TYPE_ARGS=$RSYNC_TYPE_ARGS" -i" RSYNC_TYPE_ARGS=$RSYNC_TYPE_ARGS" -i"
fi fi
if [ "$DELETE_VANISHED_FILES" == "yes" ]; then if [ "$DELETE_VANISHED_FILES" == true ]; then
RSYNC_TYPE_ARGS=$RSYNC_TYPE_ARGS" --delete" RSYNC_TYPE_ARGS=$RSYNC_TYPE_ARGS" --delete"
fi fi
@ -1834,12 +1852,12 @@ function Init {
function Main { function Main {
__CheckArguments 0 $# "$@" #__WITH_PARANOIA_DEBUG __CheckArguments 0 $# "$@" #__WITH_PARANOIA_DEBUG
if [ "$SQL_BACKUP" != "no" ] && [ $CAN_BACKUP_SQL == true ]; then if [ "$SQL_BACKUP" != false ] && [ $CAN_BACKUP_SQL == true ]; then
ListDatabases ListDatabases
fi fi
if [ "$FILE_BACKUP" != "no" ] && [ $CAN_BACKUP_FILES == true ]; then if [ "$FILE_BACKUP" != false ] && [ $CAN_BACKUP_FILES == true ]; then
ListRecursiveBackupDirectories ListRecursiveBackupDirectories
if [ "$GET_BACKUP_SIZE" != "no" ]; then if [ "$GET_BACKUP_SIZE" != false ]; then
GetDirectoriesSize GetDirectoriesSize
else else
TOTAL_FILES_SIZE=-1 TOTAL_FILES_SIZE=-1
@ -1853,21 +1871,21 @@ function Main {
SSH_PASSWORD_FILE="${SSH_PASSWORD_FILE/#\~/$HOME}" SSH_PASSWORD_FILE="${SSH_PASSWORD_FILE/#\~/$HOME}"
ENCRYPT_PUBKEY="${ENCRYPT_PUBKEY/#\~/$HOME}" ENCRYPT_PUBKEY="${ENCRYPT_PUBKEY/#\~/$HOME}"
if [ "$CREATE_DIRS" != "no" ]; then if [ "$CREATE_DIRS" != false ]; then
CreateStorageDirectories CreateStorageDirectories
fi fi
CheckDiskSpace CheckDiskSpace
# Actual backup process # Actual backup process
if [ "$SQL_BACKUP" != "no" ] && [ $CAN_BACKUP_SQL == true ]; then if [ "$SQL_BACKUP" != false ] && [ $CAN_BACKUP_SQL == true ]; then
if [ $_DRYRUN == false ] && [ "$ROTATE_SQL_BACKUPS" == "yes" ]; then if [ $_DRYRUN == false ] && [ "$ROTATE_SQL_BACKUPS" == true ]; then
RotateBackups "$SQL_STORAGE" "$ROTATE_SQL_COPIES" RotateBackups "$SQL_STORAGE" "$ROTATE_SQL_COPIES"
fi fi
BackupDatabases BackupDatabases
fi fi
if [ "$FILE_BACKUP" != "no" ] && [ $CAN_BACKUP_FILES == true ]; then if [ "$FILE_BACKUP" != false ] && [ $CAN_BACKUP_FILES == true ]; then
if [ $_DRYRUN == false ] && [ "$ROTATE_FILE_BACKUPS" == "yes" ]; then if [ $_DRYRUN == false ] && [ "$ROTATE_FILE_BACKUPS" == true ]; then
RotateBackups "$FILE_STORAGE" "$ROTATE_FILE_COPIES" RotateBackups "$FILE_STORAGE" "$ROTATE_FILE_COPIES"
fi fi
## Add Rsync include / exclude patterns ## Add Rsync include / exclude patterns
@ -1880,7 +1898,7 @@ function Usage {
__CheckArguments 0 $# "$@" #__WITH_PARANOIA_DEBUG __CheckArguments 0 $# "$@" #__WITH_PARANOIA_DEBUG
if [ "$IS_STABLE" != "yes" ]; then if [ "$IS_STABLE" != true ]; then
echo -e "\e[93mThis is an unstable dev build. Please use with caution.\e[0m" echo -e "\e[93mThis is an unstable dev build. Please use with caution.\e[0m"
fi fi
@ -2038,6 +2056,9 @@ else
LOG_FILE="$LOGFILE" LOG_FILE="$LOGFILE"
fi fi
# v2.3 config syntax compatibility
UpdateBooleans
if [ ! -w "$(dirname $LOG_FILE)" ]; then if [ ! -w "$(dirname $LOG_FILE)" ]; then
echo "Cannot write to log [$(dirname $LOG_FILE)]." echo "Cannot write to log [$(dirname $LOG_FILE)]."
else else
@ -2054,18 +2075,18 @@ if [ $no_maxtime == true ]; then
fi fi
if [ $partial_transfers == true ]; then if [ $partial_transfers == true ]; then
PARTIAL="yes" PARTIAL=true
fi fi
if [ $delete_vanished == true ]; then if [ $delete_vanished == true ]; then
DELETE_VANISHED_FILES="yes" DELETE_VANISHED_FILES=true
fi fi
if [ $dont_get_backup_size == true ]; then if [ $dont_get_backup_size == true ]; then
GET_BACKUP_SIZE="no" GET_BACKUP_SIZE=false
fi fi
if [ "$IS_STABLE" != "yes" ]; then if [ "$IS_STABLE" != true ]; then
Logger "This is an unstable dev build [$PROGRAM_BUILD]. Please use with caution." "WARN" Logger "This is an unstable dev build [$PROGRAM_BUILD]. Please use with caution." "WARN"
fi fi

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
## Generic and highly portable bash functions written in 2013-2018 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr ## Generic and highly portable bash functions written in 2013-2019 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr
#TODO: ExecTasks postponed arrays / files grow a lot. Consider having them "rolling" (cleaned at numberOfEvents) #TODO: ExecTasks postponed arrays / files grow a lot. Consider having them "rolling" (cleaned at numberOfEvents)
#TODO: command line arguments don't take -AaqV for example #TODO: command line arguments don't take -AaqV for example
@ -9,7 +9,7 @@
## PROGRAM=program-name ## PROGRAM=program-name
## INSTANCE_ID=program-instance-name ## INSTANCE_ID=program-instance-name
## _DEBUG=yes/no ## _DEBUG=true/false
## _LOGGER_SILENT=true/false ## _LOGGER_SILENT=true/false
## _LOGGER_VERBOSE=true/false ## _LOGGER_VERBOSE=true/false
## _LOGGER_ERR_ONLY=true/false ## _LOGGER_ERR_ONLY=true/false
@ -31,7 +31,7 @@
#### OFUNCTIONS MINI SUBSET #### #### OFUNCTIONS MINI SUBSET ####
#### OFUNCTIONS MICRO SUBSET #### #### OFUNCTIONS MICRO SUBSET ####
_OFUNCTIONS_VERSION=2.3.0-RC2 _OFUNCTIONS_VERSION=2.3.0-RC2
_OFUNCTIONS_BUILD=2018122103 _OFUNCTIONS_BUILD=2019012801
#### _OFUNCTIONS_BOOTSTRAP SUBSET #### #### _OFUNCTIONS_BOOTSTRAP SUBSET ####
_OFUNCTIONS_BOOTSTRAP=true _OFUNCTIONS_BOOTSTRAP=true
#### _OFUNCTIONS_BOOTSTRAP SUBSET END #### #### _OFUNCTIONS_BOOTSTRAP SUBSET END ####
@ -66,13 +66,13 @@ WARN_ALERT=false
#### DEBUG SUBSET #### #### DEBUG SUBSET ####
## allow function call checks #__WITH_PARANOIA_DEBUG ## allow function call checks #__WITH_PARANOIA_DEBUG
if [ "$_PARANOIA_DEBUG" == "yes" ];then #__WITH_PARANOIA_DEBUG if [ "$_PARANOIA_DEBUG" == true ];then #__WITH_PARANOIA_DEBUG
_DEBUG=yes #__WITH_PARANOIA_DEBUG _DEBUG=true #__WITH_PARANOIA_DEBUG
fi #__WITH_PARANOIA_DEBUG fi #__WITH_PARANOIA_DEBUG
## allow debugging from command line with _DEBUG=yes ## allow debugging from command line with _DEBUG=true
if [ ! "$_DEBUG" == "yes" ]; then if [ ! "$_DEBUG" == true ]; then
_DEBUG=no _DEBUG=false
_LOGGER_VERBOSE=false _LOGGER_VERBOSE=false
else else
trap 'TrapError ${LINENO} $?' ERR trap 'TrapError ${LINENO} $?' ERR
@ -226,19 +226,19 @@ function RemoteLogger {
if [ "$level" == "CRITICAL" ]; then if [ "$level" == "CRITICAL" ]; then
_Logger "" "$prefix\e[1;33;41m$value\e[0m" true _Logger "" "$prefix\e[1;33;41m$value\e[0m" true
if [ $_DEBUG == "yes" ]; then if [ $_DEBUG == true ]; then
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true _Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
fi fi
return return
elif [ "$level" == "ERROR" ]; then elif [ "$level" == "ERROR" ]; then
_Logger "" "$prefix\e[31m$value\e[0m" true _Logger "" "$prefix\e[31m$value\e[0m" true
if [ $_DEBUG == "yes" ]; then if [ $_DEBUG == true ]; then
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true _Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
fi fi
return return
elif [ "$level" == "WARN" ]; then elif [ "$level" == "WARN" ]; then
_Logger "" "$prefix\e[33m$value\e[0m" true _Logger "" "$prefix\e[33m$value\e[0m" true
if [ $_DEBUG == "yes" ]; then if [ $_DEBUG == true ]; then
_Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true _Logger -e "" "[$retval] in [$(joinString , ${FUNCNAME[@]})] SP=$SCRIPT_PID P=$$" true
fi fi
return return
@ -256,12 +256,12 @@ function RemoteLogger {
_Logger "" "$prefix$value" _Logger "" "$prefix$value"
return return
elif [ "$level" == "DEBUG" ]; then elif [ "$level" == "DEBUG" ]; then
if [ "$_DEBUG" == "yes" ]; then if [ "$_DEBUG" == true ]; then
_Logger "" "$prefix$value" _Logger "" "$prefix$value"
return return
fi fi
elif [ "$level" == "PARANOIA_DEBUG" ]; then #__WITH_PARANOIA_DEBUG elif [ "$level" == "PARANOIA_DEBUG" ]; then #__WITH_PARANOIA_DEBUG
if [ "$_PARANOIA_DEBUG" == "yes" ]; then #__WITH_PARANOIA_DEBUG if [ "$_PARANOIA_DEBUG" == true ]; then #__WITH_PARANOIA_DEBUG
_Logger "" "$prefix\e[35m$value\e[0m" #__WITH_PARANOIA_DEBUG _Logger "" "$prefix\e[35m$value\e[0m" #__WITH_PARANOIA_DEBUG
return #__WITH_PARANOIA_DEBUG return #__WITH_PARANOIA_DEBUG
fi #__WITH_PARANOIA_DEBUG fi #__WITH_PARANOIA_DEBUG
@ -284,10 +284,9 @@ function RemoteLogger {
# CRITICAL, ERROR, WARN sent to stderr, color depending on level, level also logged # CRITICAL, ERROR, WARN sent to stderr, color depending on level, level also logged
# NOTICE sent to stdout # NOTICE sent to stdout
# VERBOSE sent to stdout if _LOGGER_VERBOSE = true # VERBOSE sent to stdout if _LOGGER_VERBOSE=true
# ALWAYS is sent to stdout unless _LOGGER_SILENT = true # ALWAYS is sent to stdout unless _LOGGER_SILENT=true
# DEBUG & PARANOIA_DEBUG are only sent to stdout if _DEBUG=yes # DEBUG & PARANOIA_DEBUG are only sent to stdout if _DEBUG=true
# SIMPLE is a wrapper for QuickLogger that does not use advanced functionality
function Logger { function Logger {
local value="${1}" # Sentence to log (in double quotes) local value="${1}" # Sentence to log (in double quotes)
local level="${2}" # Log level local level="${2}" # Log level
@ -337,22 +336,15 @@ function Logger {
_Logger "$prefix$value" "$prefix$value" _Logger "$prefix$value" "$prefix$value"
return return
elif [ "$level" == "DEBUG" ]; then elif [ "$level" == "DEBUG" ]; then
if [ "$_DEBUG" == "yes" ]; then if [ "$_DEBUG" == true ]; then
_Logger "$prefix$value" "$prefix$value" _Logger "$prefix$value" "$prefix$value"
return return
fi fi
elif [ "$level" == "PARANOIA_DEBUG" ]; then #__WITH_PARANOIA_DEBUG elif [ "$level" == "PARANOIA_DEBUG" ]; then #__WITH_PARANOIA_DEBUG
if [ "$_PARANOIA_DEBUG" == "yes" ]; then #__WITH_PARANOIA_DEBUG if [ "$_PARANOIA_DEBUG" == true ]; then #__WITH_PARANOIA_DEBUG
_Logger "$prefix$value" "$prefix\e[35m$value\e[0m" #__WITH_PARANOIA_DEBUG _Logger "$prefix$value" "$prefix\e[35m$value\e[0m" #__WITH_PARANOIA_DEBUG
return #__WITH_PARANOIA_DEBUG return #__WITH_PARANOIA_DEBUG
fi #__WITH_PARANOIA_DEBUG fi #__WITH_PARANOIA_DEBUG
elif [ "$level" == "SIMPLE" ]; then
if [ "$_LOGGER_SILENT" == true ]; then
_Logger "$preix$value"
else
_Logger "$preix$value" "$prefix$value"
fi
return
else else
_Logger "\e[41mLogger function called without proper loglevel [$level].\e[0m" "\e[41mLogger function called without proper loglevel [$level].\e[0m" true _Logger "\e[41mLogger function called without proper loglevel [$level].\e[0m" "\e[41mLogger function called without proper loglevel [$level].\e[0m" true
_Logger "Value was: $prefix$value" "Value was: $prefix$value" true _Logger "Value was: $prefix$value" "Value was: $prefix$value" true
@ -451,7 +443,7 @@ function KillAllChilds {
#### CleanUp SUBSET #### #### CleanUp SUBSET ####
function CleanUp { function CleanUp {
if [ "$_DEBUG" != "yes" ]; then if [ "$_DEBUG" != true ]; then
rm -f "$RUN_DIR/$PROGRAM."*".$SCRIPT_PID.$TSTAMP" rm -f "$RUN_DIR/$PROGRAM."*".$SCRIPT_PID.$TSTAMP"
# Fix for sed -i requiring backup extension for BSD & Mac (see all sed -i statements) # Fix for sed -i requiring backup extension for BSD & Mac (see all sed -i statements)
rm -f "$RUN_DIR/$PROGRAM."*".$SCRIPT_PID.$TSTAMP.tmp" rm -f "$RUN_DIR/$PROGRAM."*".$SCRIPT_PID.$TSTAMP.tmp"
@ -494,7 +486,7 @@ function SendAlert {
return 0 return 0
fi fi
if [ "$_DEBUG" == "yes" ]; then if [ "$_DEBUG" == true ]; then
Logger "Debug mode, no warning mail will be sent." "NOTICE" Logger "Debug mode, no warning mail will be sent." "NOTICE"
return 0 return 0
fi fi
@ -573,8 +565,9 @@ function SendEmail {
local i local i
if [ "${destinationMails[@]}" != "" ]; then if [ "${destinationMails}" != "" ]; then
for i in "${destinationMails[@]}"; do # Not quoted since we split at space character, and emails cannot contain spaces
for i in ${destinationMails}; do
if [ $(CheckRFC822 "$i") -ne 1 ]; then if [ $(CheckRFC822 "$i") -ne 1 ]; then
Logger "Given email [$i] does not seem to be valid." "WARN" Logger "Given email [$i] does not seem to be valid." "WARN"
fi fi
@ -756,7 +749,7 @@ function LoadConfigFile {
else else
revisionPresent=$(GetConfFileValue "$configFile" "CONFIG_FILE_REVISION" true) revisionPresent=$(GetConfFileValue "$configFile" "CONFIG_FILE_REVISION" true)
if [ "$(IsNumeric $revisionPresent)" -eq 0 ]; then if [ "$(IsNumeric $revisionPresent)" -eq 0 ]; then
revisionPresent=0 Logger "CONFIG_FILE_REVISION does not seem numeric [$revisionPresent]." "DEBUG"
fi fi
if [ "$revisionRequired" != "" ]; then if [ "$revisionRequired" != "" ]; then
if [ $(VerComp "$revisionPresent" "$revisionRequired") -eq 2 ]; then if [ $(VerComp "$revisionPresent" "$revisionRequired") -eq 2 ]; then
@ -898,7 +891,7 @@ function ExecTasks {
Logger "${FUNCNAME[0]} id [$id] called by [${FUNCNAME[1]} < ${FUNCNAME[2]} < ${FUNCNAME[3]} < ${FUNCNAME[4]} < ${FUNCNAME[5]} < ${FUNCNAME[6]} ...]." "PARANOIA_DEBUG" #__WITH_PARANOIA_DEBUG Logger "${FUNCNAME[0]} id [$id] called by [${FUNCNAME[1]} < ${FUNCNAME[2]} < ${FUNCNAME[3]} < ${FUNCNAME[4]} < ${FUNCNAME[5]} < ${FUNCNAME[6]} ...]." "PARANOIA_DEBUG" #__WITH_PARANOIA_DEBUG
# Since ExecTasks takes up to 17 arguments, do a quick preflight check in DEBUG mode # Since ExecTasks takes up to 17 arguments, do a quick preflight check in DEBUG mode
if [ "$_DEBUG" == "yes" ]; then if [ "$_DEBUG" == true ]; then
declare -a booleans=(readFromFile counting spinner noTimeErrorLog noErrorLogsAtAll) declare -a booleans=(readFromFile counting spinner noTimeErrorLog noErrorLogsAtAll)
for i in "${booleans[@]}"; do for i in "${booleans[@]}"; do
test="if [ \$$i != false ] && [ \$$i != true ]; then Logger \"Bogus $i value [\$$i] given to ${FUNCNAME[0]}.\" \"CRITICAL\"; exit 1; fi" test="if [ \$$i != false ] && [ \$$i != true ]; then Logger \"Bogus $i value [\$$i] given to ${FUNCNAME[0]}.\" \"CRITICAL\"; exit 1; fi"
@ -1145,7 +1138,7 @@ function ExecTasks {
# Trivial wait time for bash to not eat up all CPU # Trivial wait time for bash to not eat up all CPU
sleep $sleepTime sleep $sleepTime
if [ "$_PERF_PROFILER" == "yes" ]; then ##__WITH_PARANOIA_DEBUG if [ "$_PERF_PROFILER" == true ]; then ##__WITH_PARANOIA_DEBUG
_PerfProfiler ##__WITH_PARANOIA_DEBUG _PerfProfiler ##__WITH_PARANOIA_DEBUG
fi ##__WITH_PARANOIA_DEBUG fi ##__WITH_PARANOIA_DEBUG
@ -1512,7 +1505,7 @@ function GetLocalOS {
LOCAL_OS="BusyBox" LOCAL_OS="BusyBox"
;; ;;
*) *)
if [ "$IGNORE_OS_TYPE" == "yes" ]; then if [ "$IGNORE_OS_TYPE" == true ]; then
Logger "Running on unknown local OS [$localOsVar]." "WARN" Logger "Running on unknown local OS [$localOsVar]." "WARN"
return return
fi fi
@ -1570,7 +1563,7 @@ function GetLocalOS {
function __CheckArguments { function __CheckArguments {
# Checks the number of arguments of a function and raises an error if some are missing # Checks the number of arguments of a function and raises an error if some are missing
if [ "$_DEBUG" == "yes" ]; then if [ "$_DEBUG" == true ]; then
local numberOfArguments="${1}" # Number of arguments the tested function should have, can be a number of a range, eg 0-2 for zero to two arguments local numberOfArguments="${1}" # Number of arguments the tested function should have, can be a number of a range, eg 0-2 for zero to two arguments
local numberOfGivenArguments="${2}" # Number of arguments that have been passed local numberOfGivenArguments="${2}" # Number of arguments that have been passed
@ -1627,7 +1620,7 @@ function __CheckArguments {
function GetRemoteOS { function GetRemoteOS {
__CheckArguments 0 $# "$@" #__WITH_PARANOIA_DEBUG __CheckArguments 0 $# "$@" #__WITH_PARANOIA_DEBUG
if [ "$REMOTE_OPERATION" != "yes" ]; then if [ "$REMOTE_OPERATION" != true ]; then
return 0 return 0
fi fi
@ -1744,7 +1737,7 @@ ENDSSH
exit 1 exit 1
;; ;;
*) *)
if [ "$IGNORE_OS_TYPE" == "yes" ]; then #DOC: Undocumented debug only setting if [ "$IGNORE_OS_TYPE" == true ]; then #DOC: Undocumented debug only setting
Logger "Running on unknown remote OS [$remoteOsVar]." "WARN" Logger "Running on unknown remote OS [$remoteOsVar]." "WARN"
return return
fi fi
@ -1784,7 +1777,7 @@ function RunLocalCommand {
Logger "Command output:\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP)" "NOTICE" Logger "Command output:\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP)" "NOTICE"
fi fi
if [ "$STOP_ON_CMD_ERROR" == "yes" ] && [ $retval -ne 0 ]; then if [ "$STOP_ON_CMD_ERROR" == true ] && [ $retval -ne 0 ]; then
Logger "Stopping on command execution error." "CRITICAL" Logger "Stopping on command execution error." "CRITICAL"
exit 1 exit 1
fi fi
@ -1797,7 +1790,7 @@ function RunRemoteCommand {
__CheckArguments 2 $# "$@" #__WITH_PARANOIA_DEBUG __CheckArguments 2 $# "$@" #__WITH_PARANOIA_DEBUG
if [ "$REMOTE_OPERATION" != "yes" ]; then if [ "$REMOTE_OPERATION" != true ]; then
Logger "Ignoring remote command [$command] because remote host is not configured." "WARN" Logger "Ignoring remote command [$command] because remote host is not configured." "WARN"
return 0 return 0
fi fi
@ -1827,7 +1820,7 @@ function RunRemoteCommand {
Logger "Command output:\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP)" "NOTICE" Logger "Command output:\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP)" "NOTICE"
fi fi
if [ "$STOP_ON_CMD_ERROR" == "yes" ] && [ $retval -ne 0 ]; then if [ "$STOP_ON_CMD_ERROR" == true ] && [ $retval -ne 0 ]; then
Logger "Stopping on command execution error." "CRITICAL" Logger "Stopping on command execution error." "CRITICAL"
exit 1 exit 1
fi fi
@ -1878,9 +1871,9 @@ function CheckConnectivityRemoteHost {
local retval local retval
if [ "$_PARANOIA_DEBUG" != "yes" ]; then # Do not loose time in paranoia debug #__WITH_PARANOIA_DEBUG if [ "$_PARANOIA_DEBUG" != true ]; then # Do not loose time in paranoia debug #__WITH_PARANOIA_DEBUG
if [ "$REMOTE_HOST_PING" != "no" ] && [ "$REMOTE_OPERATION" != "no" ]; then if [ "$REMOTE_HOST_PING" != false ] && [ "$REMOTE_OPERATION" != false ]; then
eval "$PING_CMD $REMOTE_HOST > /dev/null 2>&1" & eval "$PING_CMD $REMOTE_HOST > /dev/null 2>&1" &
ExecTasks $! "${FUNCNAME[0]}" false 0 0 60 180 true $SLEEP_TIME $KEEP_LOGGING ExecTasks $! "${FUNCNAME[0]}" false 0 0 60 180 true $SLEEP_TIME $KEEP_LOGGING
#ExecTasks "${FUNCNAME[0]}" 0 0 60 180 $SLEEP_TIME $KEEP_LOGGING true true false false 1 $! #ExecTasks "${FUNCNAME[0]}" 0 0 60 180 $SLEEP_TIME $KEEP_LOGGING true true false false 1 $!
@ -1900,7 +1893,7 @@ function CheckConnectivity3rdPartyHosts {
local retval local retval
local i local i
if [ "$_PARANOIA_DEBUG" != "yes" ]; then # Do not loose time in paranoia debug #__WITH_PARANOIA_DEBUG if [ "$_PARANOIA_DEBUG" != true ]; then # Do not loose time in paranoia debug #__WITH_PARANOIA_DEBUG
if [ "$REMOTE_3RD_PARTY_HOSTS" != "" ]; then if [ "$REMOTE_3RD_PARTY_HOSTS" != "" ]; then
remote3rdPartySuccess=false remote3rdPartySuccess=false
@ -2013,14 +2006,14 @@ function PreInit {
local compressionString local compressionString
## SSH compression ## SSH compression
if [ "$SSH_COMPRESSION" != "no" ]; then if [ "$SSH_COMPRESSION" != false ]; then
SSH_COMP=-C SSH_COMP=-C
else else
SSH_COMP= SSH_COMP=
fi fi
## Ignore SSH known host verification ## Ignore SSH known host verification
if [ "$SSH_IGNORE_KNOWN_HOSTS" == "yes" ]; then if [ "$SSH_IGNORE_KNOWN_HOSTS" == true ]; then
SSH_OPTS="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" SSH_OPTS="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
fi fi
@ -2030,7 +2023,7 @@ function PreInit {
fi fi
## Sudo execution option ## Sudo execution option
if [ "$SUDO_EXEC" == "yes" ]; then if [ "$SUDO_EXEC" == true ]; then
if [ "$RSYNC_REMOTE_PATH" != "" ]; then if [ "$RSYNC_REMOTE_PATH" != "" ]; then
RSYNC_PATH="sudo $RSYNC_REMOTE_PATH/$RSYNC_EXECUTABLE" RSYNC_PATH="sudo $RSYNC_REMOTE_PATH/$RSYNC_EXECUTABLE"
else else
@ -2194,19 +2187,19 @@ function InitRemoteOSDependingSettings {
fi fi
RSYNC_ATTR_ARGS="" RSYNC_ATTR_ARGS=""
if [ "$PRESERVE_PERMISSIONS" != "no" ]; then if [ "$PRESERVE_PERMISSIONS" != false ]; then
RSYNC_ATTR_ARGS=$RSYNC_ATTR_ARGS" -p" RSYNC_ATTR_ARGS=$RSYNC_ATTR_ARGS" -p"
fi fi
if [ "$PRESERVE_OWNER" != "no" ]; then if [ "$PRESERVE_OWNER" != false ]; then
RSYNC_ATTR_ARGS=$RSYNC_ATTR_ARGS" -o" RSYNC_ATTR_ARGS=$RSYNC_ATTR_ARGS" -o"
fi fi
if [ "$PRESERVE_GROUP" != "no" ]; then if [ "$PRESERVE_GROUP" != false ]; then
RSYNC_ATTR_ARGS=$RSYNC_ATTR_ARGS" -g" RSYNC_ATTR_ARGS=$RSYNC_ATTR_ARGS" -g"
fi fi
if [ "$PRESERVE_EXECUTABILITY" != "no" ]; then if [ "$PRESERVE_EXECUTABILITY" != false ]; then
RSYNC_ATTR_ARGS=$RSYNC_ATTR_ARGS" --executability" RSYNC_ATTR_ARGS=$RSYNC_ATTR_ARGS" --executability"
fi fi
if [ "$PRESERVE_ACL" == "yes" ]; then if [ "$PRESERVE_ACL" == true ]; then
if [ "$LOCAL_OS" != "MacOSX" ] && [ "$REMOTE_OS" != "MacOSX" ] && [ "$LOCAL_OS" != "msys" ] && [ "$REMOTE_OS" != "msys" ] && [ "$LOCAL_OS" != "Cygwin" ] && [ "$REMOTE_OS" != "Cygwin" ] && [ "$LOCAL_OS" != "BusyBox" ] && [ "$REMOTE_OS" != "BusyBox" ] && [ "$LOCAL_OS" != "Android" ] && [ "$REMOTE_OS" != "Android" ]; then if [ "$LOCAL_OS" != "MacOSX" ] && [ "$REMOTE_OS" != "MacOSX" ] && [ "$LOCAL_OS" != "msys" ] && [ "$REMOTE_OS" != "msys" ] && [ "$LOCAL_OS" != "Cygwin" ] && [ "$REMOTE_OS" != "Cygwin" ] && [ "$LOCAL_OS" != "BusyBox" ] && [ "$REMOTE_OS" != "BusyBox" ] && [ "$LOCAL_OS" != "Android" ] && [ "$REMOTE_OS" != "Android" ]; then
RSYNC_ATTR_ARGS=$RSYNC_ATTR_ARGS" -A" RSYNC_ATTR_ARGS=$RSYNC_ATTR_ARGS" -A"
else else
@ -2214,45 +2207,45 @@ function InitRemoteOSDependingSettings {
fi fi
fi fi
if [ "$PRESERVE_XATTR" == "yes" ]; then if [ "$PRESERVE_XATTR" == true ]; then
if [ "$LOCAL_OS" != "MacOSX" ] && [ "$REMOTE_OS" != "MacOSX" ] && [ "$LOCAL_OS" != "msys" ] && [ "$REMOTE_OS" != "msys" ] && [ "$LOCAL_OS" != "Cygwin" ] && [ "$REMOTE_OS" != "Cygwin" ] && [ "$LOCAL_OS" != "BusyBox" ] && [ "$REMOTE_OS" != "BusyBox" ]; then if [ "$LOCAL_OS" != "MacOSX" ] && [ "$REMOTE_OS" != "MacOSX" ] && [ "$LOCAL_OS" != "msys" ] && [ "$REMOTE_OS" != "msys" ] && [ "$LOCAL_OS" != "Cygwin" ] && [ "$REMOTE_OS" != "Cygwin" ] && [ "$LOCAL_OS" != "BusyBox" ] && [ "$REMOTE_OS" != "BusyBox" ]; then
RSYNC_ATTR_ARGS=$RSYNC_ATTR_ARGS" -X" RSYNC_ATTR_ARGS=$RSYNC_ATTR_ARGS" -X"
else else
Logger "Disabling extended attributes synchronization on [$LOCAL_OS] due to lack of support." "NOTICE" Logger "Disabling extended attributes synchronization on [$LOCAL_OS] due to lack of support." "NOTICE"
fi fi
fi fi
if [ "$RSYNC_COMPRESS" == "yes" ]; then if [ "$RSYNC_COMPRESS" == true ]; then
if [ "$LOCAL_OS" != "MacOSX" ] && [ "$REMOTE_OS" != "MacOSX" ]; then if [ "$LOCAL_OS" != "MacOSX" ] && [ "$REMOTE_OS" != "MacOSX" ]; then
RSYNC_DEFAULT_ARGS=$RSYNC_DEFAULT_ARGS" -zz --skip-compress=gz/xz/lz/lzma/lzo/rz/jpg/mp3/mp4/7z/bz2/rar/zip/sfark/s7z/ace/apk/arc/cab/dmg/jar/kgb/lzh/lha/lzx/pak/sfx" RSYNC_DEFAULT_ARGS=$RSYNC_DEFAULT_ARGS" -zz --skip-compress=gz/xz/lz/lzma/lzo/rz/jpg/mp3/mp4/7z/bz2/rar/zip/sfark/s7z/ace/apk/arc/cab/dmg/jar/kgb/lzh/lha/lzx/pak/sfx"
else else
Logger "Disabling compression skips on synchronization on [$LOCAL_OS] due to lack of support." "NOTICE" Logger "Disabling compression skips on synchronization on [$LOCAL_OS] due to lack of support." "NOTICE"
fi fi
fi fi
if [ "$COPY_SYMLINKS" == "yes" ]; then if [ "$COPY_SYMLINKS" == true ]; then
RSYNC_DEFAULT_ARGS=$RSYNC_DEFAULT_ARGS" -L" RSYNC_DEFAULT_ARGS=$RSYNC_DEFAULT_ARGS" -L"
fi fi
if [ "$KEEP_DIRLINKS" == "yes" ]; then if [ "$KEEP_DIRLINKS" == true ]; then
RSYNC_DEFAULT_ARGS=$RSYNC_DEFAULT_ARGS" -K" RSYNC_DEFAULT_ARGS=$RSYNC_DEFAULT_ARGS" -K"
fi fi
if [ "$RSYNC_OPTIONAL_ARGS" != "" ]; then if [ "$RSYNC_OPTIONAL_ARGS" != "" ]; then
RSYNC_DEFAULT_ARGS=$RSYNC_DEFAULT_ARGS" "$RSYNC_OPTIONAL_ARGS RSYNC_DEFAULT_ARGS=$RSYNC_DEFAULT_ARGS" "$RSYNC_OPTIONAL_ARGS
fi fi
if [ "$PRESERVE_HARDLINKS" == "yes" ]; then if [ "$PRESERVE_HARDLINKS" == true ]; then
RSYNC_DEFAULT_ARGS=$RSYNC_DEFAULT_ARGS" -H" RSYNC_DEFAULT_ARGS=$RSYNC_DEFAULT_ARGS" -H"
fi fi
if [ "$CHECKSUM" == "yes" ]; then if [ "$CHECKSUM" == true ]; then
RSYNC_TYPE_ARGS=$RSYNC_TYPE_ARGS" --checksum" RSYNC_TYPE_ARGS=$RSYNC_TYPE_ARGS" --checksum"
fi fi
if [ "$BANDWIDTH" != "" ] && [ "$BANDWIDTH" != "0" ]; then if [ "$BANDWIDTH" != "" ] && [ "$BANDWIDTH" != "0" ]; then
RSYNC_DEFAULT_ARGS=$RSYNC_DEFAULT_ARGS" --bwlimit=$BANDWIDTH" RSYNC_DEFAULT_ARGS=$RSYNC_DEFAULT_ARGS" --bwlimit=$BANDWIDTH"
fi fi
if [ "$PARTIAL" == "yes" ]; then if [ "$PARTIAL" == true ]; then
RSYNC_DEFAULT_ARGS=$RSYNC_DEFAULT_ARGS" --partial --partial-dir=\"$PARTIAL_DIR\"" RSYNC_DEFAULT_ARGS=$RSYNC_DEFAULT_ARGS" --partial --partial-dir=\"$PARTIAL_DIR\""
RSYNC_PARTIAL_EXCLUDE="--exclude=\"$PARTIAL_DIR\"" RSYNC_PARTIAL_EXCLUDE="--exclude=\"$PARTIAL_DIR\""
fi fi
if [ "$DELTA_COPIES" != "no" ]; then if [ "$DELTA_COPIES" != false ]; then
RSYNC_DEFAULT_ARGS=$RSYNC_DEFAULT_ARGS" --no-whole-file" RSYNC_DEFAULT_ARGS=$RSYNC_DEFAULT_ARGS" --no-whole-file"
else else
RSYNC_DEFAULT_ARGS=$RSYNC_DEFAULT_ARGS" --whole-file" RSYNC_DEFAULT_ARGS=$RSYNC_DEFAULT_ARGS" --whole-file"

View File

@ -13,8 +13,8 @@ INSTANCE_ID="test-backup"
LOGFILE="" LOGFILE=""
## Elements to backup ## Elements to backup
SQL_BACKUP=yes SQL_BACKUP=true
FILE_BACKUP=yes FILE_BACKUP=true
## Backups can be done local, pulled from another server or pushed to a backup server. Available options are [local,pull,push]. ## Backups can be done local, pulled from another server or pushed to a backup server. Available options are [local,pull,push].
## Pulled backups are the safest option, as the backup server contains the RSA key and cannot be compromised by another server. ## Pulled backups are the safest option, as the backup server contains the RSA key and cannot be compromised by another server.
@ -29,7 +29,7 @@ FILE_STORAGE="/home/storage/backup/files"
## Backup encryption using GPG and rsync. ## Backup encryption using GPG and rsync.
## Push backups get encrypted locally in CRYPT_STORAGE before they are sent to the remote system ## Push backups get encrypted locally in CRYPT_STORAGE before they are sent to the remote system
## Local and pull backups get encrypted after backup, in CRYPT_STORAGE ## Local and pull backups get encrypted after backup, in CRYPT_STORAGE
ENCRYPTION=no ENCRYPTION=false
## Backup encryption needs a temporary storage space in order to encrypt files before sending them (absolute paths of the local or remote system) ## Backup encryption needs a temporary storage space in order to encrypt files before sending them (absolute paths of the local or remote system)
## In case of a pull backup, an encrypted copy of FILE_BACKUP goes here ## In case of a pull backup, an encrypted copy of FILE_BACKUP goes here
@ -42,17 +42,17 @@ GPG_RECIPIENT="John Doe"
PARALLEL_ENCRYPTION_PROCESSES= PARALLEL_ENCRYPTION_PROCESSES=
## Create backup directories if they do not exist ## Create backup directories if they do not exist
CREATE_DIRS=yes CREATE_DIRS=true
## Keep absolute source path in your backup, eg: /your/backup/storage/the/remote/server/files ## Keep absolute source path in your backup, eg: /your/backup/storage/the/remote/server/files
## You should leave this enabled if you intend to use 'backup task division' functionality of oBackup, or everything will end up in the same directory. ## You should leave this enabled if you intend to use 'backup task division' functionality of oBackup, or everything will end up in the same directory.
KEEP_ABSOLUTE_PATHS=yes KEEP_ABSOLUTE_PATHS=true
## Generate an alert if backup size is lower than given value in Kb (this can also help identifying empty mount dirs). ## Generate an alert if backup size is lower than given value in Kb (this can also help identifying empty mount dirs).
BACKUP_SIZE_MINIMUM=1024 BACKUP_SIZE_MINIMUM=1024
## Check backup size before proceeding ## Check backup size before proceeding
GET_BACKUP_SIZE=yes GET_BACKUP_SIZE=true
## Generate an alert if storage free space is lower than given value in Kb. ## Generate an alert if storage free space is lower than given value in Kb.
## Keep in mind that disabling backup file size test will only test min space against SQL backup size. ## Keep in mind that disabling backup file size test will only test min space against SQL backup size.
@ -74,23 +74,23 @@ SSH_PASSWORD_FILE=""
_REMOTE_TOKEN=SomeAlphaNumericToken9 _REMOTE_TOKEN=SomeAlphaNumericToken9
## ssh compression should be used unless your remote connection is good enough (LAN) ## ssh compression should be used unless your remote connection is good enough (LAN)
SSH_COMPRESSION=yes SSH_COMPRESSION=true
## Ignore ssh known hosts verification. DANGER WILL ROBINSON DANGER: This can lead to security risks. Only enable if you know what you're doing. ## Ignore ssh known hosts verification. DANGER WILL ROBINSON DANGER: This can lead to security risks. Only enable if you know what you're doing.
## Works on Redhat / CentOS, doesn't work on Debian / Ubunutu ## Works on Redhat / CentOS, doesn't work on Debian / Ubunutu
SSH_IGNORE_KNOWN_HOSTS=no SSH_IGNORE_KNOWN_HOSTS=false
## Remote rsync executable path. Leave this empty in most cases ## Remote rsync executable path. Leave this empty in most cases
RSYNC_REMOTE_PATH="" RSYNC_REMOTE_PATH=""
## Check for connectivity to remote host before launching remote backup tasks. Be sure the hosts responds to ping. Failing to ping will skip current task. ## Check for connectivity to remote host before launching remote backup tasks. Be sure the hosts responds to ping. Failing to ping will skip current task.
REMOTE_HOST_PING=yes REMOTE_HOST_PING=true
## Check for internet access by pinging one or more 3rd party hosts before remote backup tasks. Leave empty if you don't want this check to be be performed. Failing to ping will skip current task. ## Check for internet access by pinging one or more 3rd party hosts before remote backup tasks. Leave empty if you don't want this check to be be performed. Failing to ping will skip current task.
REMOTE_3RD_PARTY_HOSTS="www.kernel.org www.google.com" REMOTE_3RD_PARTY_HOSTS="www.kernel.org www.google.com"
## If enabled, commands will be executed as superuser on remote side. See documentation for /etc/sudoers configuration ("find", "du", "tee" and "rsync" need to be allowed). Requiretty needs to be disabled. ## If enabled, commands will be executed as superuser on remote side. See documentation for /etc/sudoers configuration ("find", "du", "tee" and "rsync" need to be allowed). Requiretty needs to be disabled.
SUDO_EXEC=no SUDO_EXEC=false
###### DATABASE SPECIFIC OPTIONS ###### DATABASE SPECIFIC OPTIONS
@ -99,9 +99,9 @@ SQL_USER=root
## Enabling the following option will save all databases on local or remote given SQL instance except the ones specified in the exclude list. ## Enabling the following option will save all databases on local or remote given SQL instance except the ones specified in the exclude list.
## Every found database will be backed up as separate backup task. ## Every found database will be backed up as separate backup task.
DATABASES_ALL=yes DATABASES_ALL=true
DATABASES_ALL_EXCLUDE_LIST="test;mysql" DATABASES_ALL_EXCLUDE_LIST="test;mysql"
## Alternatively, if DATABASES_ALL=no, you can specify a list of databases to backup separated by semi-colons. ## Alternatively, if DATABASES_ALL=false, you can specify a list of databases to backup separated by semi-colons.
#DATABASES_LIST="somedatabase" #DATABASES_LIST="somedatabase"
## Max backup execution time per Database task. Soft max exec time generates a warning only. Hard max exec time generates a warning and stops current backup task. ## Max backup execution time per Database task. Soft max exec time generates a warning only. Hard max exec time generates a warning and stops current backup task.
@ -157,40 +157,40 @@ PATH_SEPARATOR_CHAR=";"
RSYNC_OPTIONAL_ARGS="" RSYNC_OPTIONAL_ARGS=""
## Preserve basic linux permissions ## Preserve basic linux permissions
PRESERVE_PERMISSIONS=yes PRESERVE_PERMISSIONS=true
PRESERVE_OWNER=yes PRESERVE_OWNER=true
PRESERVE_GROUP=yes PRESERVE_GROUP=true
## On MACOS X, does not work and will be ignored ## On MACOS X, does not work and will be ignored
PRESERVE_EXECUTABILITY=yes PRESERVE_EXECUTABILITY=true
## Preserve ACLS. Make sure source and target FS can hold same ACLs or you'll get loads of errors. ## Preserve ACLS. Make sure source and target FS can hold same ACLs or you'll get loads of errors.
PRESERVE_ACL=no PRESERVE_ACL=false
## Preserve Xattr. MAke sure source and target FS can hold same Xattr or you'll get loads of errors. ## Preserve Xattr. MAke sure source and target FS can hold same Xattr or you'll get loads of errors.
PRESERVE_XATTR=no PRESERVE_XATTR=false
## Transforms symlinks into referent files/dirs ## Transforms symlinks into referent files/dirs
COPY_SYMLINKS=yes COPY_SYMLINKS=true
## Treat symlinked dirs as dirs. CAUTION: This also follows symlinks outside of the replica root. ## Treat symlinked dirs as dirs. CAUTION: This also follows symlinks outside of the replica root.
KEEP_DIRLINKS=yes KEEP_DIRLINKS=true
## Preserve hard links. Make sure source and target FS can manage hard links or you will lose them. ## Preserve hard links. Make sure source and target FS can manage hard links or you will lose them.
PRESERVE_HARDLINKS=no PRESERVE_HARDLINKS=false
## Let RSYNC compress file transfers. Do not use this on local-local backup schemes. Also, this is not useful if SSH compression is enabled. ## Let RSYNC compress file transfers. Do not use this on local-local backup schemes. Also, this is not useful if SSH compression is enabled.
RSYNC_COMPRESS=no RSYNC_COMPRESS=false
## Max execution time per file backup task. Soft is warning only. Hard is warning, stopping backup and processing next one one file list. Tilme is specified in seconds ## Max execution time per file backup task. Soft is warning only. Hard is warning, stopping backup and processing next one one file list. Tilme is specified in seconds
SOFT_MAX_EXEC_TIME_FILE_TASK=3600 SOFT_MAX_EXEC_TIME_FILE_TASK=3600
HARD_MAX_EXEC_TIME_FILE_TASK=7200 HARD_MAX_EXEC_TIME_FILE_TASK=7200
## Keep partial uploads that can be resumed on next run, experimental feature ## Keep partial uploads that can be resumed on next run, experimental feature
PARTIAL=no PARTIAL=false
## Delete files on destination that vanished from source. Do not turn this on unless you enabled backup rotation or a snapshotting FS like zfs to keep those vanished files on the destination. ## Delete files on destination that vanished from source. Do not turn this on unless you enabled backup rotation or a snapshotting FS like zfs to keep those vanished files on the destination.
DELETE_VANISHED_FILES=no DELETE_VANISHED_FILES=false
## Use delta copy algortithm (usefull when local paths are network drives), defaults to yes ## Use delta copy algortithm (usefull when local paths are network drives), defaults to true
DELTA_COPIES=yes DELTA_COPIES=true
## Bandwidth limit Kbytes / second for file backups. Leave 0 to disable limitation. ## Bandwidth limit Kbytes / second for file backups. Leave 0 to disable limitation.
BANDWIDTH=0 BANDWIDTH=0
@ -228,9 +228,9 @@ HARD_MAX_EXEC_TIME_TOTAL=36000
KEEP_LOGGING=1801 KEEP_LOGGING=1801
## Backup Rotation. You may rotate backups if you don't use snapshots on your backup server. ## Backup Rotation. You may rotate backups if you don't use snapshots on your backup server.
ROTATE_SQL_BACKUPS=no ROTATE_SQL_BACKUPS=false
ROTATE_SQL_COPIES=7 ROTATE_SQL_COPIES=7
ROTATE_FILE_BACKUPS=no ROTATE_FILE_BACKUPS=false
ROTATE_FILE_COPIES=7 ROTATE_FILE_COPIES=7
###### EXECUTION HOOKS ###### EXECUTION HOOKS
@ -248,7 +248,7 @@ MAX_EXEC_TIME_PER_CMD_BEFORE=0
MAX_EXEC_TIME_PER_CMD_AFTER=0 MAX_EXEC_TIME_PER_CMD_AFTER=0
## Stops whole backup execution if one of the above commands fail ## Stops whole backup execution if one of the above commands fail
STOP_ON_CMD_ERROR=no STOP_ON_CMD_ERROR=false
## Run local and remote after backup cmd's even on failure ## Run local and remote after backup cmd's even on failure
RUN_AFTER_CMD_ON_ERROR=no RUN_AFTER_CMD_ON_ERROR=false