mirror of
https://github.com/deajan/obackup.git
synced 2024-11-15 04:03:41 +01:00
Rebuilt targets
This commit is contained in:
parent
45464074ef
commit
8b5965ae4a
@ -4,11 +4,11 @@
|
|||||||
|
|
||||||
###### Remote push/pull (or local) backup script for files & databases
|
###### Remote push/pull (or local) backup script for files & databases
|
||||||
PROGRAM="obackup"
|
PROGRAM="obackup"
|
||||||
AUTHOR="(C) 2013-2018 by Orsiris de Jong"
|
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=no
|
IS_STABLE=yes
|
||||||
|
|
||||||
#### Execution order #__WITH_PARANOIA_DEBUG
|
#### Execution order #__WITH_PARANOIA_DEBUG
|
||||||
# GetLocalOS #__WITH_PARANOIA_DEBUG
|
# GetLocalOS #__WITH_PARANOIA_DEBUG
|
||||||
@ -35,7 +35,7 @@ IS_STABLE=no
|
|||||||
# FilesBackup #__WITH_PARANOIA_DEBUG
|
# FilesBackup #__WITH_PARANOIA_DEBUG
|
||||||
|
|
||||||
_OFUNCTIONS_VERSION=2.3.0-RC2
|
_OFUNCTIONS_VERSION=2.3.0-RC2
|
||||||
_OFUNCTIONS_BUILD=2018110502
|
_OFUNCTIONS_BUILD=2018122103
|
||||||
_OFUNCTIONS_BOOTSTRAP=true
|
_OFUNCTIONS_BOOTSTRAP=true
|
||||||
|
|
||||||
if ! type "$BASH" > /dev/null; then
|
if ! type "$BASH" > /dev/null; then
|
||||||
@ -728,9 +728,11 @@ function TrapError {
|
|||||||
|
|
||||||
function LoadConfigFile {
|
function LoadConfigFile {
|
||||||
local configFile="${1}"
|
local configFile="${1}"
|
||||||
|
local revisionRequired="${2}"
|
||||||
|
|
||||||
__CheckArguments 1 $# "$@" #__WITH_PARANOIA_DEBUG
|
__CheckArguments 1 $# "$@" #__WITH_PARANOIA_DEBUG
|
||||||
|
|
||||||
|
local revisionPresent
|
||||||
|
|
||||||
if [ ! -f "$configFile" ]; then
|
if [ ! -f "$configFile" ]; then
|
||||||
Logger "Cannot load configuration file [$configFile]. Cannot start." "CRITICAL"
|
Logger "Cannot load configuration file [$configFile]. Cannot start." "CRITICAL"
|
||||||
@ -739,6 +741,16 @@ function LoadConfigFile {
|
|||||||
Logger "Wrong configuration file supplied [$configFile]. Cannot start." "CRITICAL"
|
Logger "Wrong configuration file supplied [$configFile]. Cannot start." "CRITICAL"
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
|
revisionPresent=$(GetConfFileValue "$configFile" "CONFIG_FILE_REVISION" true)
|
||||||
|
if [ "$(IsNumeric $revisionPresent)" -eq 0 ]; then
|
||||||
|
revisionPresent=0
|
||||||
|
fi
|
||||||
|
if [ "$revisionRequired" != "" ]; then
|
||||||
|
if [ $(VerComp "$revisionPresent" "$revisionRequired") -eq 2 ]; then
|
||||||
|
Logger "Configuration file seems out of date. Required version [$revisionRequired]. Actual version [$revisionPresent]." "CRITICAL"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
# Remove everything that is not a variable assignation
|
# Remove everything that is not a variable assignation
|
||||||
grep '^[^ ]*=[^;&]*' "$configFile" > "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP"
|
grep '^[^ ]*=[^;&]*' "$configFile" > "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP"
|
||||||
source "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP"
|
source "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP"
|
||||||
@ -895,7 +907,8 @@ function ExecTasks {
|
|||||||
local commandsConditionArray=() # Array containing conditional commands
|
local commandsConditionArray=() # Array containing conditional commands
|
||||||
local currentCommand # Variable containing currently processed command
|
local currentCommand # Variable containing currently processed command
|
||||||
local currentCommandCondition # Variable containing currently processed conditional command
|
local currentCommandCondition # Variable containing currently processed conditional command
|
||||||
local commandsArrayPid=() # Array containing pids of commands currently run
|
local commandsArrayPid=() # Array containing commands indexed by pids
|
||||||
|
local commandsArrayOutput=() # Array contining command results indexed by pids
|
||||||
local postponedRetryCount=0 # Number of current postponed commands retries
|
local postponedRetryCount=0 # Number of current postponed commands retries
|
||||||
local postponedItemCount=0 # Number of commands that have been postponed (keep at least one in order to check once)
|
local postponedItemCount=0 # Number of commands that have been postponed (keep at least one in order to check once)
|
||||||
local postponedCounter=0
|
local postponedCounter=0
|
||||||
@ -924,8 +937,9 @@ function ExecTasks {
|
|||||||
local executeCommand # Boolean to check if currentCommand can be executed given a condition
|
local executeCommand # Boolean to check if currentCommand can be executed given a condition
|
||||||
local hasPids=false # Are any valable pids given to function ? #__WITH_PARANOIA_DEBUG
|
local hasPids=false # Are any valable pids given to function ? #__WITH_PARANOIA_DEBUG
|
||||||
local functionMode
|
local functionMode
|
||||||
local softAlert=false
|
local softAlert=false # Does a soft alert need to be triggered, if yes, send an alert once
|
||||||
local failedPidsList # List containing failed pids with exit code separated by semicolons (eg : 2355:1;4534:2;2354:3)
|
local failedPidsList # List containing failed pids with exit code separated by semicolons (eg : 2355:1;4534:2;2354:3)
|
||||||
|
local randomOutputName # Random filename for command outputs
|
||||||
|
|
||||||
# Initialise global variable
|
# Initialise global variable
|
||||||
eval "WAIT_FOR_TASK_COMPLETION_$id=\"\""
|
eval "WAIT_FOR_TASK_COMPLETION_$id=\"\""
|
||||||
@ -1090,6 +1104,9 @@ function ExecTasks {
|
|||||||
if [ "$functionMode" == "ParallelExec" ]; then
|
if [ "$functionMode" == "ParallelExec" ]; then
|
||||||
Logger "Command was [${commandsArrayPid[$pid]}]." "ERROR"
|
Logger "Command was [${commandsArrayPid[$pid]}]." "ERROR"
|
||||||
fi
|
fi
|
||||||
|
if [ -f "${commandsArrayOutput[$pid]}" ]; then
|
||||||
|
Logger "Command output was [\$(cat ${commandsArrayOutput[$pid]})\n]." "ERROR"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
errorcount=$((errorcount+1))
|
errorcount=$((errorcount+1))
|
||||||
# Welcome to variable variable bash hell
|
# Welcome to variable variable bash hell
|
||||||
@ -1233,10 +1250,12 @@ function ExecTasks {
|
|||||||
|
|
||||||
if [ $executeCommand == true ]; then
|
if [ $executeCommand == true ]; then
|
||||||
Logger "Running command [$currentCommand]." "DEBUG"
|
Logger "Running command [$currentCommand]." "DEBUG"
|
||||||
eval "$currentCommand" >> "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$id.$SCRIPT_PID.$TSTAMP" 2>&1 &
|
randomOutputName=$(date '+%Y%m%dT%H%M%S').$(PoorMansRandomGenerator 5)
|
||||||
|
eval "$currentCommand" >> "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$randomOutputName.$SCRIPT_PID.$TSTAMP" 2>&1 &
|
||||||
pid=$!
|
pid=$!
|
||||||
pidsArray+=($pid)
|
pidsArray+=($pid)
|
||||||
commandsArrayPid[$pid]="$currentCommand"
|
commandsArrayPid[$pid]="$currentCommand"
|
||||||
|
commandsArrayOutput[$pid]="$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$randomOutputName.$SCRIPT_PID.$TSTAMP"
|
||||||
# Initialize pid execution time array
|
# Initialize pid execution time array
|
||||||
pidsTimeArray[$pid]=0
|
pidsTimeArray[$pid]=0
|
||||||
else
|
else
|
||||||
|
32
install.sh
32
install.sh
@ -10,7 +10,7 @@ PROGRAM_BINARY=$PROGRAM".sh"
|
|||||||
PROGRAM_BATCH=$PROGRAM"-batch.sh"
|
PROGRAM_BATCH=$PROGRAM"-batch.sh"
|
||||||
SSH_FILTER="ssh_filter.sh"
|
SSH_FILTER="ssh_filter.sh"
|
||||||
|
|
||||||
SCRIPT_BUILD=2018100201
|
SCRIPT_BUILD=2018100206
|
||||||
INSTANCE_ID="installer-$SCRIPT_BUILD"
|
INSTANCE_ID="installer-$SCRIPT_BUILD"
|
||||||
|
|
||||||
## osync / obackup / pmocr / zsnap install script
|
## osync / obackup / pmocr / zsnap install script
|
||||||
@ -18,7 +18,7 @@ INSTANCE_ID="installer-$SCRIPT_BUILD"
|
|||||||
## Please adapt this to fit your distro needs
|
## Please adapt this to fit your distro needs
|
||||||
|
|
||||||
_OFUNCTIONS_VERSION=2.3.0-RC2
|
_OFUNCTIONS_VERSION=2.3.0-RC2
|
||||||
_OFUNCTIONS_BUILD=2018110502
|
_OFUNCTIONS_BUILD=2018122103
|
||||||
_OFUNCTIONS_BOOTSTRAP=true
|
_OFUNCTIONS_BOOTSTRAP=true
|
||||||
|
|
||||||
if ! type "$BASH" > /dev/null; then
|
if ! type "$BASH" > /dev/null; then
|
||||||
@ -700,9 +700,17 @@ function GetInit {
|
|||||||
|
|
||||||
function CreateDir {
|
function CreateDir {
|
||||||
local dir="${1}"
|
local dir="${1}"
|
||||||
|
local dirMask="${2}"
|
||||||
|
local dirUser="${3}"
|
||||||
|
local dirGroup="${4}"
|
||||||
|
|
||||||
if [ ! -d "$dir" ]; then
|
if [ ! -d "$dir" ]; then
|
||||||
|
(
|
||||||
|
if [ $(IsInteger $dirMask) -eq 1 ]; then
|
||||||
|
umask $dirMask
|
||||||
|
fi
|
||||||
mkdir -p "$dir"
|
mkdir -p "$dir"
|
||||||
|
)
|
||||||
if [ $? == 0 ]; then
|
if [ $? == 0 ]; then
|
||||||
Logger "Created directory [$dir]." "SIMPLE"
|
Logger "Created directory [$dir]." "SIMPLE"
|
||||||
else
|
else
|
||||||
@ -710,6 +718,20 @@ function CreateDir {
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$dirUser" != "" ]; then
|
||||||
|
userGroup="$dirUser"
|
||||||
|
if [ "$dirGroup" != "" ]; then
|
||||||
|
userGroup="$userGroup"":$dirGroup"
|
||||||
|
fi
|
||||||
|
chown "$userGroup" "$dir"
|
||||||
|
if [ $? != 0 ]; then
|
||||||
|
Logger "Could not set directory ownership on [$dir] to [$userGroup]." "SIMPLE"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
Logger "Set file ownership on [$dir] to [$userGroup]." "SIMPLE"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function CopyFile {
|
function CopyFile {
|
||||||
@ -741,7 +763,7 @@ function CopyFile {
|
|||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
Logger "Copied [$sourcePath/$sourceFileName] to [$destPath/$destFileName]." "SIMPLE"
|
Logger "Copied [$sourcePath/$sourceFileName] to [$destPath/$destFileName]." "SIMPLE"
|
||||||
if [ "$fileMod" != "" ]; then
|
if [ "$(IsInteger $fileMod)" -eq 1 ]; then
|
||||||
chmod "$fileMod" "$destPath/$destFileName"
|
chmod "$fileMod" "$destPath/$destFileName"
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
Logger "Cannot set file permissions of [$destPath/$destFileName] to [$fileMod]." "SIMPLE"
|
Logger "Cannot set file permissions of [$destPath/$destFileName] to [$fileMod]." "SIMPLE"
|
||||||
@ -749,6 +771,8 @@ function CopyFile {
|
|||||||
else
|
else
|
||||||
Logger "Set file permissions to [$fileMod] on [$destPath/$destFileName]." "SIMPLE"
|
Logger "Set file permissions to [$fileMod] on [$destPath/$destFileName]." "SIMPLE"
|
||||||
fi
|
fi
|
||||||
|
elif [ "$fileMod" != "" ]; then
|
||||||
|
Logger "Bogus filemod [$fileMod] for [$destPath] given." "SIMPLE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$fileUser" != "" ]; then
|
if [ "$fileUser" != "" ]; then
|
||||||
@ -927,6 +951,8 @@ else
|
|||||||
Logger "Script begin, logging to [$LOG_FILE]." "DEBUG"
|
Logger "Script begin, logging to [$LOG_FILE]." "DEBUG"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Set default umask
|
||||||
|
umask 0022
|
||||||
|
|
||||||
GetLocalOS
|
GetLocalOS
|
||||||
SetLocalOSSettings
|
SetLocalOSSettings
|
||||||
|
31
obackup.sh
31
obackup.sh
@ -4,15 +4,15 @@
|
|||||||
|
|
||||||
###### Remote push/pull (or local) backup script for files & databases
|
###### Remote push/pull (or local) backup script for files & databases
|
||||||
PROGRAM="obackup"
|
PROGRAM="obackup"
|
||||||
AUTHOR="(C) 2013-2018 by Orsiris de Jong"
|
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=no
|
IS_STABLE=yes
|
||||||
|
|
||||||
|
|
||||||
_OFUNCTIONS_VERSION=2.3.0-RC2
|
_OFUNCTIONS_VERSION=2.3.0-RC2
|
||||||
_OFUNCTIONS_BUILD=2018110502
|
_OFUNCTIONS_BUILD=2018122103
|
||||||
_OFUNCTIONS_BOOTSTRAP=true
|
_OFUNCTIONS_BOOTSTRAP=true
|
||||||
|
|
||||||
if ! type "$BASH" > /dev/null; then
|
if ! type "$BASH" > /dev/null; then
|
||||||
@ -687,8 +687,10 @@ function TrapError {
|
|||||||
|
|
||||||
function LoadConfigFile {
|
function LoadConfigFile {
|
||||||
local configFile="${1}"
|
local configFile="${1}"
|
||||||
|
local revisionRequired="${2}"
|
||||||
|
|
||||||
|
|
||||||
|
local revisionPresent
|
||||||
|
|
||||||
if [ ! -f "$configFile" ]; then
|
if [ ! -f "$configFile" ]; then
|
||||||
Logger "Cannot load configuration file [$configFile]. Cannot start." "CRITICAL"
|
Logger "Cannot load configuration file [$configFile]. Cannot start." "CRITICAL"
|
||||||
@ -697,6 +699,16 @@ function LoadConfigFile {
|
|||||||
Logger "Wrong configuration file supplied [$configFile]. Cannot start." "CRITICAL"
|
Logger "Wrong configuration file supplied [$configFile]. Cannot start." "CRITICAL"
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
|
revisionPresent=$(GetConfFileValue "$configFile" "CONFIG_FILE_REVISION" true)
|
||||||
|
if [ "$(IsNumeric $revisionPresent)" -eq 0 ]; then
|
||||||
|
revisionPresent=0
|
||||||
|
fi
|
||||||
|
if [ "$revisionRequired" != "" ]; then
|
||||||
|
if [ $(VerComp "$revisionPresent" "$revisionRequired") -eq 2 ]; then
|
||||||
|
Logger "Configuration file seems out of date. Required version [$revisionRequired]. Actual version [$revisionPresent]." "CRITICAL"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
# Remove everything that is not a variable assignation
|
# Remove everything that is not a variable assignation
|
||||||
grep '^[^ ]*=[^;&]*' "$configFile" > "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP"
|
grep '^[^ ]*=[^;&]*' "$configFile" > "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP"
|
||||||
source "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP"
|
source "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP"
|
||||||
@ -835,7 +847,8 @@ function ExecTasks {
|
|||||||
local commandsConditionArray=() # Array containing conditional commands
|
local commandsConditionArray=() # Array containing conditional commands
|
||||||
local currentCommand # Variable containing currently processed command
|
local currentCommand # Variable containing currently processed command
|
||||||
local currentCommandCondition # Variable containing currently processed conditional command
|
local currentCommandCondition # Variable containing currently processed conditional command
|
||||||
local commandsArrayPid=() # Array containing pids of commands currently run
|
local commandsArrayPid=() # Array containing commands indexed by pids
|
||||||
|
local commandsArrayOutput=() # Array contining command results indexed by pids
|
||||||
local postponedRetryCount=0 # Number of current postponed commands retries
|
local postponedRetryCount=0 # Number of current postponed commands retries
|
||||||
local postponedItemCount=0 # Number of commands that have been postponed (keep at least one in order to check once)
|
local postponedItemCount=0 # Number of commands that have been postponed (keep at least one in order to check once)
|
||||||
local postponedCounter=0
|
local postponedCounter=0
|
||||||
@ -863,8 +876,9 @@ function ExecTasks {
|
|||||||
local pidsTimeArray # Array containing execution begin time of pids
|
local pidsTimeArray # Array containing execution begin time of pids
|
||||||
local executeCommand # Boolean to check if currentCommand can be executed given a condition
|
local executeCommand # Boolean to check if currentCommand can be executed given a condition
|
||||||
local functionMode
|
local functionMode
|
||||||
local softAlert=false
|
local softAlert=false # Does a soft alert need to be triggered, if yes, send an alert once
|
||||||
local failedPidsList # List containing failed pids with exit code separated by semicolons (eg : 2355:1;4534:2;2354:3)
|
local failedPidsList # List containing failed pids with exit code separated by semicolons (eg : 2355:1;4534:2;2354:3)
|
||||||
|
local randomOutputName # Random filename for command outputs
|
||||||
|
|
||||||
# Initialise global variable
|
# Initialise global variable
|
||||||
eval "WAIT_FOR_TASK_COMPLETION_$id=\"\""
|
eval "WAIT_FOR_TASK_COMPLETION_$id=\"\""
|
||||||
@ -1028,6 +1042,9 @@ function ExecTasks {
|
|||||||
if [ "$functionMode" == "ParallelExec" ]; then
|
if [ "$functionMode" == "ParallelExec" ]; then
|
||||||
Logger "Command was [${commandsArrayPid[$pid]}]." "ERROR"
|
Logger "Command was [${commandsArrayPid[$pid]}]." "ERROR"
|
||||||
fi
|
fi
|
||||||
|
if [ -f "${commandsArrayOutput[$pid]}" ]; then
|
||||||
|
Logger "Command output was [\$(cat ${commandsArrayOutput[$pid]})\n]." "ERROR"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
errorcount=$((errorcount+1))
|
errorcount=$((errorcount+1))
|
||||||
# Welcome to variable variable bash hell
|
# Welcome to variable variable bash hell
|
||||||
@ -1164,10 +1181,12 @@ function ExecTasks {
|
|||||||
|
|
||||||
if [ $executeCommand == true ]; then
|
if [ $executeCommand == true ]; then
|
||||||
Logger "Running command [$currentCommand]." "DEBUG"
|
Logger "Running command [$currentCommand]." "DEBUG"
|
||||||
eval "$currentCommand" >> "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$id.$SCRIPT_PID.$TSTAMP" 2>&1 &
|
randomOutputName=$(date '+%Y%m%dT%H%M%S').$(PoorMansRandomGenerator 5)
|
||||||
|
eval "$currentCommand" >> "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$randomOutputName.$SCRIPT_PID.$TSTAMP" 2>&1 &
|
||||||
pid=$!
|
pid=$!
|
||||||
pidsArray+=($pid)
|
pidsArray+=($pid)
|
||||||
commandsArrayPid[$pid]="$currentCommand"
|
commandsArrayPid[$pid]="$currentCommand"
|
||||||
|
commandsArrayOutput[$pid]="$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$randomOutputName.$SCRIPT_PID.$TSTAMP"
|
||||||
# Initialize pid execution time array
|
# Initialize pid execution time array
|
||||||
pidsTimeArray[$pid]=0
|
pidsTimeArray[$pid]=0
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user