mirror of
https://github.com/deajan/obackup.git
synced 2024-12-26 07:23:41 +01:00
Rebuilt targets
This commit is contained in:
parent
ec5720623d
commit
0d958ed923
@ -1,14 +1,11 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#TODO: rework old IFS= statements
|
|
||||||
|
|
||||||
|
|
||||||
###### 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-2016 by Orsiris de Jong"
|
AUTHOR="(C) 2013-2016 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-dev
|
PROGRAM_VERSION=2.1-dev
|
||||||
PROGRAM_BUILD=2016080801
|
PROGRAM_BUILD=2016080804
|
||||||
IS_STABLE=yes
|
IS_STABLE=yes
|
||||||
|
|
||||||
#### MINIMAL-FUNCTION-SET BEGIN ####
|
#### MINIMAL-FUNCTION-SET BEGIN ####
|
||||||
@ -1487,10 +1484,12 @@ function _ListDatabasesRemote {
|
|||||||
function ListDatabases {
|
function ListDatabases {
|
||||||
__CheckArguments 0 $# ${FUNCNAME[0]} "$@" #__WITH_PARANOIA_DEBUG
|
__CheckArguments 0 $# ${FUNCNAME[0]} "$@" #__WITH_PARANOIA_DEBUG
|
||||||
|
|
||||||
local output_file # Return of subfunction
|
local outputFile # Return of subfunction
|
||||||
local db_name
|
local dbName
|
||||||
local db_size
|
local dbSize
|
||||||
local db_backup
|
local dbBackup
|
||||||
|
|
||||||
|
local dbArray
|
||||||
|
|
||||||
if [ $CAN_BACKUP_SQL -ne 1 ]; then
|
if [ $CAN_BACKUP_SQL -ne 1 ]; then
|
||||||
Logger "Cannot list databases." "ERROR"
|
Logger "Cannot list databases." "ERROR"
|
||||||
@ -1502,61 +1501,56 @@ function ListDatabases {
|
|||||||
if [ "$BACKUP_TYPE" == "local" ] || [ "$BACKUP_TYPE" == "push" ]; then
|
if [ "$BACKUP_TYPE" == "local" ] || [ "$BACKUP_TYPE" == "push" ]; then
|
||||||
_ListDatabasesLocal
|
_ListDatabasesLocal
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
output_file=""
|
outputFile=""
|
||||||
else
|
else
|
||||||
output_file="$RUN_DIR/$PROGRAM._ListDatabasesLocal.$SCRIPT_PID"
|
outputFile="$RUN_DIR/$PROGRAM._ListDatabasesLocal.$SCRIPT_PID"
|
||||||
fi
|
fi
|
||||||
elif [ "$BACKUP_TYPE" == "pull" ]; then
|
elif [ "$BACKUP_TYPE" == "pull" ]; then
|
||||||
_ListDatabasesRemote
|
_ListDatabasesRemote
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
output_file=""
|
outputFile=""
|
||||||
else
|
else
|
||||||
output_file="$RUN_DIR/$PROGRAM._ListDatabasesRemote.$SCRIPT_PID"
|
outputFile="$RUN_DIR/$PROGRAM._ListDatabasesRemote.$SCRIPT_PID"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f "$output_file" ] && [ $CAN_BACKUP_SQL -eq 1 ]; then
|
if [ -f "$outputFile" ] && [ $CAN_BACKUP_SQL -eq 1 ]; then
|
||||||
OLD_IFS=$IFS
|
while read -r line; do
|
||||||
IFS=$' \n'
|
while read -r name size; do dbName=$name; dbSize=$size; done <<< "$line"
|
||||||
for line in $(cat "$output_file")
|
#db_name="${line% *}"
|
||||||
do
|
#db_size="${line# *}"
|
||||||
db_name=$(echo $line | cut -f1)
|
#db_name=$(echo $line | cut -f1)
|
||||||
db_size=$(echo $line | cut -f2)
|
#db_size=$(echo $line | cut -f2)
|
||||||
|
|
||||||
if [ "$DATABASES_ALL" == "yes" ]; then
|
if [ "$DATABASES_ALL" == "yes" ]; then
|
||||||
db_backup=1
|
dbBackup=1
|
||||||
IFS=$PATH_SEPARATOR_CHAR
|
IFs=$PATH_SEPARATOR_CHAR read -r -a dbArray <<< "$DATABASES_ALL_EXCLUDE_LIST"
|
||||||
for j in $DATABASES_ALL_EXCLUDE_LIST
|
for j in "${dbArray[@]}"; do
|
||||||
do
|
if [ "$dbName" == "$j" ]; then
|
||||||
if [ "$db_name" == "$j" ]; then
|
dbBackup=0
|
||||||
db_backup=0
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
IFS=$' \n'
|
|
||||||
else
|
else
|
||||||
db_backup=0
|
dbBackup=0
|
||||||
IFS=$PATH_SEPARATOR_CHAR
|
IFs=$PATH_SEPARATOR_CHAR read -r -a dbArray <<< "$DATABASES_LIST"
|
||||||
for j in $DATABASES_LIST
|
for j in "${dbArray[@]}"; do
|
||||||
do
|
if [ "$dbName" == "$j" ]; then
|
||||||
if [ "$db_name" == "$j" ]; then
|
dbBackup=1
|
||||||
db_backup=1
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
IFS=$' \n'
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $db_backup -eq 1 ]; then
|
if [ $dbBackup -eq 1 ]; then
|
||||||
if [ "$SQL_BACKUP_TASKS" != "" ]; then
|
if [ "$SQL_BACKUP_TASKS" != "" ]; then
|
||||||
SQL_BACKUP_TASKS="$SQL_BACKUP_TASKS $db_name"
|
SQL_BACKUP_TASKS="$SQL_BACKUP_TASKS $dbName"
|
||||||
else
|
else
|
||||||
SQL_BACKUP_TASKS="$db_name"
|
SQL_BACKUP_TASKS="$dbName"
|
||||||
fi
|
fi
|
||||||
TOTAL_DATABASES_SIZE=$((TOTAL_DATABASES_SIZE+$db_size))
|
TOTAL_DATABASES_SIZE=$((TOTAL_DATABASES_SIZE+$dbSize))
|
||||||
else
|
else
|
||||||
SQL_EXCLUDED_TASKS="$SQL_EXCLUDED_TASKS $db_name"
|
SQL_EXCLUDED_TASKS="$SQL_EXCLUDED_TASKS $dbName"
|
||||||
fi
|
fi
|
||||||
done
|
done < "$outputFile"
|
||||||
IFS=$OLD_IFS
|
|
||||||
|
|
||||||
Logger "Database backup list: $SQL_BACKUP_TASKS" "DEBUG"
|
Logger "Database backup list: $SQL_BACKUP_TASKS" "DEBUG"
|
||||||
Logger "Database exclude list: $SQL_EXCLUDED_TASKS" "DEBUG"
|
Logger "Database exclude list: $SQL_EXCLUDED_TASKS" "DEBUG"
|
||||||
@ -1574,7 +1568,7 @@ function _ListRecursiveBackupDirectoriesLocal {
|
|||||||
local directory
|
local directory
|
||||||
local retval
|
local retval
|
||||||
|
|
||||||
IFS=$PATH_SEPARATOR_CHAR read -a directories <<< "$RECURSIVE_DIRECTORY_LIST"
|
IFS=$PATH_SEPARATOR_CHAR read -r -a directories <<< "$RECURSIVE_DIRECTORY_LIST"
|
||||||
for directory in "${directories[@]}"; do
|
for directory in "${directories[@]}"; do
|
||||||
# No sudo here, assuming you should have all necessary rights for local checks
|
# No sudo here, assuming you should have all necessary rights for local checks
|
||||||
cmd="$FIND_CMD -L $directory/ -mindepth 1 -maxdepth 1 -type d >> $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID 2> $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID"
|
cmd="$FIND_CMD -L $directory/ -mindepth 1 -maxdepth 1 -type d >> $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID 2> $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID"
|
||||||
@ -1605,7 +1599,7 @@ function _ListRecursiveBackupDirectoriesRemote {
|
|||||||
local directory
|
local directory
|
||||||
local retval
|
local retval
|
||||||
|
|
||||||
IFS=$PATH_SEPARATOR_CHAR read -a directories <<< "$RECURSIVE_DIRECTORY_LIST"
|
IFS=$PATH_SEPARATOR_CHAR read -r -a directories <<< "$RECURSIVE_DIRECTORY_LIST"
|
||||||
for directory in "${directories[@]}"; do
|
for directory in "${directories[@]}"; do
|
||||||
cmd=$SSH_CMD' "'$COMMAND_SUDO' '$REMOTE_FIND_CMD' -L '$directory'/ -mindepth 1 -maxdepth 1 -type d" >> '$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID' 2> '$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID
|
cmd=$SSH_CMD' "'$COMMAND_SUDO' '$REMOTE_FIND_CMD' -L '$directory'/ -mindepth 1 -maxdepth 1 -type d" >> '$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID' 2> '$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID
|
||||||
Logger "cmd: $cmd" "DEBUG"
|
Logger "cmd: $cmd" "DEBUG"
|
||||||
@ -1633,6 +1627,8 @@ function ListRecursiveBackupDirectories {
|
|||||||
local output_file
|
local output_file
|
||||||
local file_exclude
|
local file_exclude
|
||||||
|
|
||||||
|
local fileArray
|
||||||
|
|
||||||
Logger "Listing directories to backup." "NOTICE"
|
Logger "Listing directories to backup." "NOTICE"
|
||||||
if [ "$BACKUP_TYPE" == "local" ] || [ "$BACKUP_TYPE" == "push" ]; then
|
if [ "$BACKUP_TYPE" == "local" ] || [ "$BACKUP_TYPE" == "push" ]; then
|
||||||
_ListRecursiveBackupDirectoriesLocal
|
_ListRecursiveBackupDirectoriesLocal
|
||||||
@ -1651,19 +1647,14 @@ function ListRecursiveBackupDirectories {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f "$output_file" ]; then
|
if [ -f "$output_file" ]; then
|
||||||
OLD_IFS=$IFS
|
while read -r line; do
|
||||||
IFS=$' \n'
|
|
||||||
for line in $(cat "$output_file")
|
|
||||||
do
|
|
||||||
file_exclude=0
|
file_exclude=0
|
||||||
IFS=$PATH_SEPARATOR_CHAR
|
IFS=$PATH_SEPARATOR_CHAR read -r -a fileArray <<< "$RECURSIVE_EXCLUDE_LIST"
|
||||||
for k in $RECURSIVE_EXCLUDE_LIST
|
for k in "${fileArray[@]}"; do
|
||||||
do
|
|
||||||
if [ "$k" == "$line" ]; then
|
if [ "$k" == "$line" ]; then
|
||||||
file_exclude=1
|
file_exclude=1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
IFS=$' \n'
|
|
||||||
|
|
||||||
if [ $file_exclude -eq 0 ]; then
|
if [ $file_exclude -eq 0 ]; then
|
||||||
if [ "$FILE_RECURSIVE_BACKUP_TASKS" == "" ]; then
|
if [ "$FILE_RECURSIVE_BACKUP_TASKS" == "" ]; then
|
||||||
@ -1676,14 +1667,11 @@ function ListRecursiveBackupDirectories {
|
|||||||
else
|
else
|
||||||
FILE_RECURSIVE_EXCLUDED_TASKS="$FILE_RECURSIVE_EXCLUDED_TASKS$PATH_SEPARATOR_CHAR$line"
|
FILE_RECURSIVE_EXCLUDED_TASKS="$FILE_RECURSIVE_EXCLUDED_TASKS$PATH_SEPARATOR_CHAR$line"
|
||||||
fi
|
fi
|
||||||
done
|
done < "$output_file"
|
||||||
IFS=$OLD_IFS
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
OLD_IFS=$IFS
|
IFS=$PATH_SEPARATOR_CHAR read -r -a fileArray <<< "$DIRECTORY_LIST"
|
||||||
IFS=$PATH_SEPARATOR_CHAR
|
for directory in "${fileArray[@]}"; do
|
||||||
for directory in $DIRECTORY_LIST
|
|
||||||
do
|
|
||||||
FILE_SIZE_LIST="$FILE_SIZE_LIST $(EscapeSpaces $directory)"
|
FILE_SIZE_LIST="$FILE_SIZE_LIST $(EscapeSpaces $directory)"
|
||||||
if [ "$FILE_BACKUP_TASKS" == "" ]; then
|
if [ "$FILE_BACKUP_TASKS" == "" ]; then
|
||||||
FILE_BACKUP_TASKS="$directory"
|
FILE_BACKUP_TASKS="$directory"
|
||||||
@ -1691,7 +1679,6 @@ function ListRecursiveBackupDirectories {
|
|||||||
FILE_BACKUP_TASKS="$FILE_BACKUP_TASKS$PATH_SEPARATOR_CHAR$directory"
|
FILE_BACKUP_TASKS="$FILE_BACKUP_TASKS$PATH_SEPARATOR_CHAR$directory"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
IFS=$OLD_IFS
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function _GetDirectoriesSizeLocal {
|
function _GetDirectoriesSizeLocal {
|
||||||
@ -1854,8 +1841,8 @@ function GetDiskSpaceLocal {
|
|||||||
Logger "Cannot get disk space in [$path_to_check] on local system." "ERROR"
|
Logger "Cannot get disk space in [$path_to_check] on local system." "ERROR"
|
||||||
Logger "Command Output:\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID)" "ERROR"
|
Logger "Command Output:\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID)" "ERROR"
|
||||||
else
|
else
|
||||||
DISK_SPACE=$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID | tail -1 | awk '{print $4}')
|
DISK_SPACE=$(tail -1 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID" | awk '{print $4}')
|
||||||
DRIVE=$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID | tail -1 | awk '{print $1}')
|
DRIVE=$(tail -1 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID" | awk '{print $1}')
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
Logger "Storage path [$path_to_check] does not exist." "CRITICAL"
|
Logger "Storage path [$path_to_check] does not exist." "CRITICAL"
|
||||||
@ -1880,8 +1867,8 @@ function GetDiskSpaceRemote {
|
|||||||
Logger "Command Output:\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID)" "ERROR"
|
Logger "Command Output:\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID)" "ERROR"
|
||||||
return 1
|
return 1
|
||||||
else
|
else
|
||||||
DISK_SPACE=$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID | tail -1 | awk '{print $4}')
|
DISK_SPACE=$(tail -1 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID" | awk '{print $4}')
|
||||||
DRIVE=$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID | tail -1 | awk '{print $1}')
|
DRIVE=$(tail -1 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID" | awk '{print $1}')
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2099,8 +2086,6 @@ function BackupDatabases {
|
|||||||
|
|
||||||
local database
|
local database
|
||||||
|
|
||||||
OLD_IFS=$IFS
|
|
||||||
IFS=$' \t\n'
|
|
||||||
for database in $SQL_BACKUP_TASKS
|
for database in $SQL_BACKUP_TASKS
|
||||||
do
|
do
|
||||||
Logger "Backing up database [$database]." "NOTICE"
|
Logger "Backing up database [$database]." "NOTICE"
|
||||||
@ -2108,7 +2093,6 @@ function BackupDatabases {
|
|||||||
WaitForTaskCompletion $! $SOFT_MAX_EXEC_TIME_DB_TASK $HARD_MAX_EXEC_TIME_DB_TASK ${FUNCNAME[0]} false true
|
WaitForTaskCompletion $! $SOFT_MAX_EXEC_TIME_DB_TASK $HARD_MAX_EXEC_TIME_DB_TASK ${FUNCNAME[0]} false true
|
||||||
CheckTotalExecutionTime
|
CheckTotalExecutionTime
|
||||||
done
|
done
|
||||||
IFS=$OLD_IFS
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function Rsync {
|
function Rsync {
|
||||||
@ -2209,7 +2193,7 @@ function FilesBackup {
|
|||||||
local backupTask
|
local backupTask
|
||||||
local backupTasks
|
local backupTasks
|
||||||
|
|
||||||
IFS=$PATH_SEPARATOR_CHAR read -a backupTasks <<< "$FILE_BACKUP_TASKS"
|
IFS=$PATH_SEPARATOR_CHAR read -r -a backupTasks <<< "$FILE_BACKUP_TASKS"
|
||||||
for backupTask in "${backupTasks[@]}"; do
|
for backupTask in "${backupTasks[@]}"; do
|
||||||
Logger "Beginning file backup of [$backupTask]." "NOTICE"
|
Logger "Beginning file backup of [$backupTask]." "NOTICE"
|
||||||
if [ "$ENCRYPTION" == "yes" ]; then
|
if [ "$ENCRYPTION" == "yes" ]; then
|
||||||
@ -2220,7 +2204,7 @@ function FilesBackup {
|
|||||||
CheckTotalExecutionTime
|
CheckTotalExecutionTime
|
||||||
done
|
done
|
||||||
|
|
||||||
IFS=$PATH_SEPARATOR_CHAR read -a backupTasks <<< "$RECURSIVE_DIRECTORY_LIST"
|
IFS=$PATH_SEPARATOR_CHAR read -r -a backupTasks <<< "$RECURSIVE_DIRECTORY_LIST"
|
||||||
for backupTask in "${backupTasks[@]}"; do
|
for backupTask in "${backupTasks[@]}"; do
|
||||||
Logger "Beginning non recursive file backup of [$backupTask]." "NOTICE"
|
Logger "Beginning non recursive file backup of [$backupTask]." "NOTICE"
|
||||||
if [ "$ENCRYPTION" == "yes" ]; then
|
if [ "$ENCRYPTION" == "yes" ]; then
|
||||||
@ -2231,12 +2215,9 @@ function FilesBackup {
|
|||||||
CheckTotalExecutionTime
|
CheckTotalExecutionTime
|
||||||
done
|
done
|
||||||
|
|
||||||
IFS=$PATH_SEPARATOR_CHAR read -a backupTasks <<< "$FILE_RECURSIVE_BACKUP_TASKS"
|
IFS=$PATH_SEPARATOR_CHAR read -r -a backupTasks <<< "$FILE_RECURSIVE_BACKUP_TASKS"
|
||||||
for backupTask in "${backupTasks[@]}"; do
|
for backupTask in "${backupTasks[@]}"; do
|
||||||
|
|
||||||
# Backup sub directories of recursive directories
|
# Backup sub directories of recursive directories
|
||||||
#for BACKUP_TASK in $FILE_RECURSIVE_BACKUP_TASKS
|
|
||||||
#do
|
|
||||||
Logger "Beginning recursive file backup of [$backupTask]." "NOTICE"
|
Logger "Beginning recursive file backup of [$backupTask]." "NOTICE"
|
||||||
if [ "$ENCRYPTION" == "yes" ]; then
|
if [ "$ENCRYPTION" == "yes" ]; then
|
||||||
Duplicity "$backupTask" "recurse"
|
Duplicity "$backupTask" "recurse"
|
||||||
@ -2245,7 +2226,6 @@ function FilesBackup {
|
|||||||
fi
|
fi
|
||||||
CheckTotalExecutionTime
|
CheckTotalExecutionTime
|
||||||
done
|
done
|
||||||
#IFS=$OLD_IFS
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function CheckTotalExecutionTime {
|
function CheckTotalExecutionTime {
|
||||||
@ -2273,13 +2253,9 @@ function _RotateBackupsLocal {
|
|||||||
local cmd
|
local cmd
|
||||||
local path
|
local path
|
||||||
|
|
||||||
OLD_IFS=$IFS
|
find "$backup_path" -iname "*.$PROGRAM.*" -print0 | while IFS= read -r -d $'\0' backup; do
|
||||||
IFS=$'\t\n'
|
|
||||||
for backup in $(ls -I "*.$PROGRAM.*" "$backup_path")
|
|
||||||
do
|
|
||||||
copy=$rotate_copies
|
copy=$rotate_copies
|
||||||
while [ $copy -gt 1 ]
|
while [ $copy -gt 1 ]; do
|
||||||
do
|
|
||||||
if [ $copy -eq $rotate_copies ]; then
|
if [ $copy -eq $rotate_copies ]; then
|
||||||
cmd="rm -rf \"$backup_path/$backup.$PROGRAM.$copy\""
|
cmd="rm -rf \"$backup_path/$backup.$PROGRAM.$copy\""
|
||||||
Logger "cmd: $cmd" "DEBUG"
|
Logger "cmd: $cmd" "DEBUG"
|
||||||
@ -2332,7 +2308,6 @@ function _RotateBackupsLocal {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
IFS=$OLD_IFS
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function _RotateBackupsRemote {
|
function _RotateBackupsRemote {
|
||||||
@ -2382,13 +2357,9 @@ function RemoteLogger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function _RotateBackupsRemoteSSH {
|
function _RotateBackupsRemoteSSH {
|
||||||
OLD_IFS=$IFS
|
find "$backup_path" -iname "*.$PROGRAM.*" -print0 | while IFS= read -r -d $'\0' backup; do
|
||||||
IFS=$'\t\n'
|
|
||||||
for backup in $(ls -I "*.$PROGRAM.*" "$backup_path")
|
|
||||||
do
|
|
||||||
copy=$rotate_copies
|
copy=$rotate_copies
|
||||||
while [ $copy -gt 1 ]
|
while [ $copy -gt 1 ]; do
|
||||||
do
|
|
||||||
if [ $copy -eq $rotate_copies ]; then
|
if [ $copy -eq $rotate_copies ]; then
|
||||||
cmd="$COMMAND_SUDO rm -rf \"$backup_path/$backup.$PROGRAM.$copy\""
|
cmd="$COMMAND_SUDO rm -rf \"$backup_path/$backup.$PROGRAM.$copy\""
|
||||||
RemoteLogger "cmd: $cmd" "DEBUG"
|
RemoteLogger "cmd: $cmd" "DEBUG"
|
||||||
@ -2436,7 +2407,6 @@ function _RotateBackupsRemoteSSH {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
IFS=$OLD_IFS
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_RotateBackupsRemoteSSH
|
_RotateBackupsRemoteSSH
|
||||||
@ -2603,8 +2573,7 @@ function GetCommandlineArguments {
|
|||||||
Usage
|
Usage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for i in "$@"
|
for i in "$@"; do
|
||||||
do
|
|
||||||
case $i in
|
case $i in
|
||||||
--dry)
|
--dry)
|
||||||
_DRYRUN=1
|
_DRYRUN=1
|
||||||
|
143
obackup.sh
143
obackup.sh
@ -1,14 +1,11 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#TODO: rework old IFS= statements
|
|
||||||
|
|
||||||
|
|
||||||
###### 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-2016 by Orsiris de Jong"
|
AUTHOR="(C) 2013-2016 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-dev
|
PROGRAM_VERSION=2.1-dev
|
||||||
PROGRAM_BUILD=2016080801
|
PROGRAM_BUILD=2016080804
|
||||||
IS_STABLE=yes
|
IS_STABLE=yes
|
||||||
|
|
||||||
#### MINIMAL-FUNCTION-SET BEGIN ####
|
#### MINIMAL-FUNCTION-SET BEGIN ####
|
||||||
@ -1407,10 +1404,12 @@ function _ListDatabasesRemote {
|
|||||||
|
|
||||||
function ListDatabases {
|
function ListDatabases {
|
||||||
|
|
||||||
local output_file # Return of subfunction
|
local outputFile # Return of subfunction
|
||||||
local db_name
|
local dbName
|
||||||
local db_size
|
local dbSize
|
||||||
local db_backup
|
local dbBackup
|
||||||
|
|
||||||
|
local dbArray
|
||||||
|
|
||||||
if [ $CAN_BACKUP_SQL -ne 1 ]; then
|
if [ $CAN_BACKUP_SQL -ne 1 ]; then
|
||||||
Logger "Cannot list databases." "ERROR"
|
Logger "Cannot list databases." "ERROR"
|
||||||
@ -1422,61 +1421,56 @@ function ListDatabases {
|
|||||||
if [ "$BACKUP_TYPE" == "local" ] || [ "$BACKUP_TYPE" == "push" ]; then
|
if [ "$BACKUP_TYPE" == "local" ] || [ "$BACKUP_TYPE" == "push" ]; then
|
||||||
_ListDatabasesLocal
|
_ListDatabasesLocal
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
output_file=""
|
outputFile=""
|
||||||
else
|
else
|
||||||
output_file="$RUN_DIR/$PROGRAM._ListDatabasesLocal.$SCRIPT_PID"
|
outputFile="$RUN_DIR/$PROGRAM._ListDatabasesLocal.$SCRIPT_PID"
|
||||||
fi
|
fi
|
||||||
elif [ "$BACKUP_TYPE" == "pull" ]; then
|
elif [ "$BACKUP_TYPE" == "pull" ]; then
|
||||||
_ListDatabasesRemote
|
_ListDatabasesRemote
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
output_file=""
|
outputFile=""
|
||||||
else
|
else
|
||||||
output_file="$RUN_DIR/$PROGRAM._ListDatabasesRemote.$SCRIPT_PID"
|
outputFile="$RUN_DIR/$PROGRAM._ListDatabasesRemote.$SCRIPT_PID"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f "$output_file" ] && [ $CAN_BACKUP_SQL -eq 1 ]; then
|
if [ -f "$outputFile" ] && [ $CAN_BACKUP_SQL -eq 1 ]; then
|
||||||
OLD_IFS=$IFS
|
while read -r line; do
|
||||||
IFS=$' \n'
|
while read -r name size; do dbName=$name; dbSize=$size; done <<< "$line"
|
||||||
for line in $(cat "$output_file")
|
#db_name="${line% *}"
|
||||||
do
|
#db_size="${line# *}"
|
||||||
db_name=$(echo $line | cut -f1)
|
#db_name=$(echo $line | cut -f1)
|
||||||
db_size=$(echo $line | cut -f2)
|
#db_size=$(echo $line | cut -f2)
|
||||||
|
|
||||||
if [ "$DATABASES_ALL" == "yes" ]; then
|
if [ "$DATABASES_ALL" == "yes" ]; then
|
||||||
db_backup=1
|
dbBackup=1
|
||||||
IFS=$PATH_SEPARATOR_CHAR
|
IFs=$PATH_SEPARATOR_CHAR read -r -a dbArray <<< "$DATABASES_ALL_EXCLUDE_LIST"
|
||||||
for j in $DATABASES_ALL_EXCLUDE_LIST
|
for j in "${dbArray[@]}"; do
|
||||||
do
|
if [ "$dbName" == "$j" ]; then
|
||||||
if [ "$db_name" == "$j" ]; then
|
dbBackup=0
|
||||||
db_backup=0
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
IFS=$' \n'
|
|
||||||
else
|
else
|
||||||
db_backup=0
|
dbBackup=0
|
||||||
IFS=$PATH_SEPARATOR_CHAR
|
IFs=$PATH_SEPARATOR_CHAR read -r -a dbArray <<< "$DATABASES_LIST"
|
||||||
for j in $DATABASES_LIST
|
for j in "${dbArray[@]}"; do
|
||||||
do
|
if [ "$dbName" == "$j" ]; then
|
||||||
if [ "$db_name" == "$j" ]; then
|
dbBackup=1
|
||||||
db_backup=1
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
IFS=$' \n'
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $db_backup -eq 1 ]; then
|
if [ $dbBackup -eq 1 ]; then
|
||||||
if [ "$SQL_BACKUP_TASKS" != "" ]; then
|
if [ "$SQL_BACKUP_TASKS" != "" ]; then
|
||||||
SQL_BACKUP_TASKS="$SQL_BACKUP_TASKS $db_name"
|
SQL_BACKUP_TASKS="$SQL_BACKUP_TASKS $dbName"
|
||||||
else
|
else
|
||||||
SQL_BACKUP_TASKS="$db_name"
|
SQL_BACKUP_TASKS="$dbName"
|
||||||
fi
|
fi
|
||||||
TOTAL_DATABASES_SIZE=$((TOTAL_DATABASES_SIZE+$db_size))
|
TOTAL_DATABASES_SIZE=$((TOTAL_DATABASES_SIZE+$dbSize))
|
||||||
else
|
else
|
||||||
SQL_EXCLUDED_TASKS="$SQL_EXCLUDED_TASKS $db_name"
|
SQL_EXCLUDED_TASKS="$SQL_EXCLUDED_TASKS $dbName"
|
||||||
fi
|
fi
|
||||||
done
|
done < "$outputFile"
|
||||||
IFS=$OLD_IFS
|
|
||||||
|
|
||||||
Logger "Database backup list: $SQL_BACKUP_TASKS" "DEBUG"
|
Logger "Database backup list: $SQL_BACKUP_TASKS" "DEBUG"
|
||||||
Logger "Database exclude list: $SQL_EXCLUDED_TASKS" "DEBUG"
|
Logger "Database exclude list: $SQL_EXCLUDED_TASKS" "DEBUG"
|
||||||
@ -1493,7 +1487,7 @@ function _ListRecursiveBackupDirectoriesLocal {
|
|||||||
local directory
|
local directory
|
||||||
local retval
|
local retval
|
||||||
|
|
||||||
IFS=$PATH_SEPARATOR_CHAR read -a directories <<< "$RECURSIVE_DIRECTORY_LIST"
|
IFS=$PATH_SEPARATOR_CHAR read -r -a directories <<< "$RECURSIVE_DIRECTORY_LIST"
|
||||||
for directory in "${directories[@]}"; do
|
for directory in "${directories[@]}"; do
|
||||||
# No sudo here, assuming you should have all necessary rights for local checks
|
# No sudo here, assuming you should have all necessary rights for local checks
|
||||||
cmd="$FIND_CMD -L $directory/ -mindepth 1 -maxdepth 1 -type d >> $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID 2> $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID"
|
cmd="$FIND_CMD -L $directory/ -mindepth 1 -maxdepth 1 -type d >> $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID 2> $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID"
|
||||||
@ -1523,7 +1517,7 @@ function _ListRecursiveBackupDirectoriesRemote {
|
|||||||
local directory
|
local directory
|
||||||
local retval
|
local retval
|
||||||
|
|
||||||
IFS=$PATH_SEPARATOR_CHAR read -a directories <<< "$RECURSIVE_DIRECTORY_LIST"
|
IFS=$PATH_SEPARATOR_CHAR read -r -a directories <<< "$RECURSIVE_DIRECTORY_LIST"
|
||||||
for directory in "${directories[@]}"; do
|
for directory in "${directories[@]}"; do
|
||||||
cmd=$SSH_CMD' "'$COMMAND_SUDO' '$REMOTE_FIND_CMD' -L '$directory'/ -mindepth 1 -maxdepth 1 -type d" >> '$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID' 2> '$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID
|
cmd=$SSH_CMD' "'$COMMAND_SUDO' '$REMOTE_FIND_CMD' -L '$directory'/ -mindepth 1 -maxdepth 1 -type d" >> '$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID' 2> '$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID
|
||||||
Logger "cmd: $cmd" "DEBUG"
|
Logger "cmd: $cmd" "DEBUG"
|
||||||
@ -1550,6 +1544,8 @@ function ListRecursiveBackupDirectories {
|
|||||||
local output_file
|
local output_file
|
||||||
local file_exclude
|
local file_exclude
|
||||||
|
|
||||||
|
local fileArray
|
||||||
|
|
||||||
Logger "Listing directories to backup." "NOTICE"
|
Logger "Listing directories to backup." "NOTICE"
|
||||||
if [ "$BACKUP_TYPE" == "local" ] || [ "$BACKUP_TYPE" == "push" ]; then
|
if [ "$BACKUP_TYPE" == "local" ] || [ "$BACKUP_TYPE" == "push" ]; then
|
||||||
_ListRecursiveBackupDirectoriesLocal
|
_ListRecursiveBackupDirectoriesLocal
|
||||||
@ -1568,19 +1564,14 @@ function ListRecursiveBackupDirectories {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f "$output_file" ]; then
|
if [ -f "$output_file" ]; then
|
||||||
OLD_IFS=$IFS
|
while read -r line; do
|
||||||
IFS=$' \n'
|
|
||||||
for line in $(cat "$output_file")
|
|
||||||
do
|
|
||||||
file_exclude=0
|
file_exclude=0
|
||||||
IFS=$PATH_SEPARATOR_CHAR
|
IFS=$PATH_SEPARATOR_CHAR read -r -a fileArray <<< "$RECURSIVE_EXCLUDE_LIST"
|
||||||
for k in $RECURSIVE_EXCLUDE_LIST
|
for k in "${fileArray[@]}"; do
|
||||||
do
|
|
||||||
if [ "$k" == "$line" ]; then
|
if [ "$k" == "$line" ]; then
|
||||||
file_exclude=1
|
file_exclude=1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
IFS=$' \n'
|
|
||||||
|
|
||||||
if [ $file_exclude -eq 0 ]; then
|
if [ $file_exclude -eq 0 ]; then
|
||||||
if [ "$FILE_RECURSIVE_BACKUP_TASKS" == "" ]; then
|
if [ "$FILE_RECURSIVE_BACKUP_TASKS" == "" ]; then
|
||||||
@ -1593,14 +1584,11 @@ function ListRecursiveBackupDirectories {
|
|||||||
else
|
else
|
||||||
FILE_RECURSIVE_EXCLUDED_TASKS="$FILE_RECURSIVE_EXCLUDED_TASKS$PATH_SEPARATOR_CHAR$line"
|
FILE_RECURSIVE_EXCLUDED_TASKS="$FILE_RECURSIVE_EXCLUDED_TASKS$PATH_SEPARATOR_CHAR$line"
|
||||||
fi
|
fi
|
||||||
done
|
done < "$output_file"
|
||||||
IFS=$OLD_IFS
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
OLD_IFS=$IFS
|
IFS=$PATH_SEPARATOR_CHAR read -r -a fileArray <<< "$DIRECTORY_LIST"
|
||||||
IFS=$PATH_SEPARATOR_CHAR
|
for directory in "${fileArray[@]}"; do
|
||||||
for directory in $DIRECTORY_LIST
|
|
||||||
do
|
|
||||||
FILE_SIZE_LIST="$FILE_SIZE_LIST $(EscapeSpaces $directory)"
|
FILE_SIZE_LIST="$FILE_SIZE_LIST $(EscapeSpaces $directory)"
|
||||||
if [ "$FILE_BACKUP_TASKS" == "" ]; then
|
if [ "$FILE_BACKUP_TASKS" == "" ]; then
|
||||||
FILE_BACKUP_TASKS="$directory"
|
FILE_BACKUP_TASKS="$directory"
|
||||||
@ -1608,7 +1596,6 @@ function ListRecursiveBackupDirectories {
|
|||||||
FILE_BACKUP_TASKS="$FILE_BACKUP_TASKS$PATH_SEPARATOR_CHAR$directory"
|
FILE_BACKUP_TASKS="$FILE_BACKUP_TASKS$PATH_SEPARATOR_CHAR$directory"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
IFS=$OLD_IFS
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function _GetDirectoriesSizeLocal {
|
function _GetDirectoriesSizeLocal {
|
||||||
@ -1764,8 +1751,8 @@ function GetDiskSpaceLocal {
|
|||||||
Logger "Cannot get disk space in [$path_to_check] on local system." "ERROR"
|
Logger "Cannot get disk space in [$path_to_check] on local system." "ERROR"
|
||||||
Logger "Command Output:\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID)" "ERROR"
|
Logger "Command Output:\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID)" "ERROR"
|
||||||
else
|
else
|
||||||
DISK_SPACE=$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID | tail -1 | awk '{print $4}')
|
DISK_SPACE=$(tail -1 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID" | awk '{print $4}')
|
||||||
DRIVE=$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID | tail -1 | awk '{print $1}')
|
DRIVE=$(tail -1 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID" | awk '{print $1}')
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
Logger "Storage path [$path_to_check] does not exist." "CRITICAL"
|
Logger "Storage path [$path_to_check] does not exist." "CRITICAL"
|
||||||
@ -1789,8 +1776,8 @@ function GetDiskSpaceRemote {
|
|||||||
Logger "Command Output:\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID)" "ERROR"
|
Logger "Command Output:\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID)" "ERROR"
|
||||||
return 1
|
return 1
|
||||||
else
|
else
|
||||||
DISK_SPACE=$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID | tail -1 | awk '{print $4}')
|
DISK_SPACE=$(tail -1 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID" | awk '{print $4}')
|
||||||
DRIVE=$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID | tail -1 | awk '{print $1}')
|
DRIVE=$(tail -1 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID" | awk '{print $1}')
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2002,8 +1989,6 @@ function BackupDatabases {
|
|||||||
|
|
||||||
local database
|
local database
|
||||||
|
|
||||||
OLD_IFS=$IFS
|
|
||||||
IFS=$' \t\n'
|
|
||||||
for database in $SQL_BACKUP_TASKS
|
for database in $SQL_BACKUP_TASKS
|
||||||
do
|
do
|
||||||
Logger "Backing up database [$database]." "NOTICE"
|
Logger "Backing up database [$database]." "NOTICE"
|
||||||
@ -2011,7 +1996,6 @@ function BackupDatabases {
|
|||||||
WaitForTaskCompletion $! $SOFT_MAX_EXEC_TIME_DB_TASK $HARD_MAX_EXEC_TIME_DB_TASK ${FUNCNAME[0]} false true
|
WaitForTaskCompletion $! $SOFT_MAX_EXEC_TIME_DB_TASK $HARD_MAX_EXEC_TIME_DB_TASK ${FUNCNAME[0]} false true
|
||||||
CheckTotalExecutionTime
|
CheckTotalExecutionTime
|
||||||
done
|
done
|
||||||
IFS=$OLD_IFS
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function Rsync {
|
function Rsync {
|
||||||
@ -2109,7 +2093,7 @@ function FilesBackup {
|
|||||||
local backupTask
|
local backupTask
|
||||||
local backupTasks
|
local backupTasks
|
||||||
|
|
||||||
IFS=$PATH_SEPARATOR_CHAR read -a backupTasks <<< "$FILE_BACKUP_TASKS"
|
IFS=$PATH_SEPARATOR_CHAR read -r -a backupTasks <<< "$FILE_BACKUP_TASKS"
|
||||||
for backupTask in "${backupTasks[@]}"; do
|
for backupTask in "${backupTasks[@]}"; do
|
||||||
Logger "Beginning file backup of [$backupTask]." "NOTICE"
|
Logger "Beginning file backup of [$backupTask]." "NOTICE"
|
||||||
if [ "$ENCRYPTION" == "yes" ]; then
|
if [ "$ENCRYPTION" == "yes" ]; then
|
||||||
@ -2120,7 +2104,7 @@ function FilesBackup {
|
|||||||
CheckTotalExecutionTime
|
CheckTotalExecutionTime
|
||||||
done
|
done
|
||||||
|
|
||||||
IFS=$PATH_SEPARATOR_CHAR read -a backupTasks <<< "$RECURSIVE_DIRECTORY_LIST"
|
IFS=$PATH_SEPARATOR_CHAR read -r -a backupTasks <<< "$RECURSIVE_DIRECTORY_LIST"
|
||||||
for backupTask in "${backupTasks[@]}"; do
|
for backupTask in "${backupTasks[@]}"; do
|
||||||
Logger "Beginning non recursive file backup of [$backupTask]." "NOTICE"
|
Logger "Beginning non recursive file backup of [$backupTask]." "NOTICE"
|
||||||
if [ "$ENCRYPTION" == "yes" ]; then
|
if [ "$ENCRYPTION" == "yes" ]; then
|
||||||
@ -2131,12 +2115,9 @@ function FilesBackup {
|
|||||||
CheckTotalExecutionTime
|
CheckTotalExecutionTime
|
||||||
done
|
done
|
||||||
|
|
||||||
IFS=$PATH_SEPARATOR_CHAR read -a backupTasks <<< "$FILE_RECURSIVE_BACKUP_TASKS"
|
IFS=$PATH_SEPARATOR_CHAR read -r -a backupTasks <<< "$FILE_RECURSIVE_BACKUP_TASKS"
|
||||||
for backupTask in "${backupTasks[@]}"; do
|
for backupTask in "${backupTasks[@]}"; do
|
||||||
|
|
||||||
# Backup sub directories of recursive directories
|
# Backup sub directories of recursive directories
|
||||||
#for BACKUP_TASK in $FILE_RECURSIVE_BACKUP_TASKS
|
|
||||||
#do
|
|
||||||
Logger "Beginning recursive file backup of [$backupTask]." "NOTICE"
|
Logger "Beginning recursive file backup of [$backupTask]." "NOTICE"
|
||||||
if [ "$ENCRYPTION" == "yes" ]; then
|
if [ "$ENCRYPTION" == "yes" ]; then
|
||||||
Duplicity "$backupTask" "recurse"
|
Duplicity "$backupTask" "recurse"
|
||||||
@ -2145,7 +2126,6 @@ function FilesBackup {
|
|||||||
fi
|
fi
|
||||||
CheckTotalExecutionTime
|
CheckTotalExecutionTime
|
||||||
done
|
done
|
||||||
#IFS=$OLD_IFS
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function CheckTotalExecutionTime {
|
function CheckTotalExecutionTime {
|
||||||
@ -2171,13 +2151,9 @@ function _RotateBackupsLocal {
|
|||||||
local cmd
|
local cmd
|
||||||
local path
|
local path
|
||||||
|
|
||||||
OLD_IFS=$IFS
|
find "$backup_path" -iname "*.$PROGRAM.*" -print0 | while IFS= read -r -d $'\0' backup; do
|
||||||
IFS=$'\t\n'
|
|
||||||
for backup in $(ls -I "*.$PROGRAM.*" "$backup_path")
|
|
||||||
do
|
|
||||||
copy=$rotate_copies
|
copy=$rotate_copies
|
||||||
while [ $copy -gt 1 ]
|
while [ $copy -gt 1 ]; do
|
||||||
do
|
|
||||||
if [ $copy -eq $rotate_copies ]; then
|
if [ $copy -eq $rotate_copies ]; then
|
||||||
cmd="rm -rf \"$backup_path/$backup.$PROGRAM.$copy\""
|
cmd="rm -rf \"$backup_path/$backup.$PROGRAM.$copy\""
|
||||||
Logger "cmd: $cmd" "DEBUG"
|
Logger "cmd: $cmd" "DEBUG"
|
||||||
@ -2230,7 +2206,6 @@ function _RotateBackupsLocal {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
IFS=$OLD_IFS
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function _RotateBackupsRemote {
|
function _RotateBackupsRemote {
|
||||||
@ -2274,13 +2249,9 @@ function RemoteLogger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function _RotateBackupsRemoteSSH {
|
function _RotateBackupsRemoteSSH {
|
||||||
OLD_IFS=$IFS
|
find "$backup_path" -iname "*.$PROGRAM.*" -print0 | while IFS= read -r -d $'\0' backup; do
|
||||||
IFS=$'\t\n'
|
|
||||||
for backup in $(ls -I "*.$PROGRAM.*" "$backup_path")
|
|
||||||
do
|
|
||||||
copy=$rotate_copies
|
copy=$rotate_copies
|
||||||
while [ $copy -gt 1 ]
|
while [ $copy -gt 1 ]; do
|
||||||
do
|
|
||||||
if [ $copy -eq $rotate_copies ]; then
|
if [ $copy -eq $rotate_copies ]; then
|
||||||
cmd="$COMMAND_SUDO rm -rf \"$backup_path/$backup.$PROGRAM.$copy\""
|
cmd="$COMMAND_SUDO rm -rf \"$backup_path/$backup.$PROGRAM.$copy\""
|
||||||
RemoteLogger "cmd: $cmd" "DEBUG"
|
RemoteLogger "cmd: $cmd" "DEBUG"
|
||||||
@ -2328,7 +2299,6 @@ function _RotateBackupsRemoteSSH {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
IFS=$OLD_IFS
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_RotateBackupsRemoteSSH
|
_RotateBackupsRemoteSSH
|
||||||
@ -2491,8 +2461,7 @@ function GetCommandlineArguments {
|
|||||||
Usage
|
Usage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for i in "$@"
|
for i in "$@"; do
|
||||||
do
|
|
||||||
case $i in
|
case $i in
|
||||||
--dry)
|
--dry)
|
||||||
_DRYRUN=1
|
_DRYRUN=1
|
||||||
|
Loading…
Reference in New Issue
Block a user