mirror of
https://github.com/deajan/obackup.git
synced 2025-02-05 19:03:50 +01:00
Small fixes for dry mode
This commit is contained in:
parent
f7c896bd53
commit
e828519c32
13
CHANGELOG.md
13
CHANGELOG.md
@ -3,13 +3,7 @@ SHORT FUTURE IMPROVEMENTS
|
|||||||
|
|
||||||
- Rewrite rsync exclude patterns using \"pattern\" instead of escaped chars
|
- Rewrite rsync exclude patterns using \"pattern\" instead of escaped chars
|
||||||
- Clean most of recursive task creation code
|
- Clean most of recursive task creation code
|
||||||
- dry option shoudln't create local dirs
|
- Add symlink support (-L) and edit find -xtype d instead of -type d (xtype won't work with FreeBSD)
|
||||||
- Add symlink support (-L) and edit find -xtype d instead of -type d
|
|
||||||
|
|
||||||
FAR FUTURE IMPROVEMENTS
|
|
||||||
-----------------------
|
|
||||||
|
|
||||||
- (Secret world domination... Still need to get bald and get a cat)
|
|
||||||
|
|
||||||
KNOWN ISSUES
|
KNOWN ISSUES
|
||||||
------------
|
------------
|
||||||
@ -17,8 +11,6 @@ KNOWN ISSUES
|
|||||||
- Backup size check does not honor rsync exclude patterns
|
- Backup size check does not honor rsync exclude patterns
|
||||||
- Bandwidth parameter is ignored for SQL backups
|
- Bandwidth parameter is ignored for SQL backups
|
||||||
- Missing symlink support when run from MSYS environment
|
- Missing symlink support when run from MSYS environment
|
||||||
- Dry mode creates dirs
|
|
||||||
- Dry mode does not try mysqldump
|
|
||||||
|
|
||||||
UNDER WORK
|
UNDER WORK
|
||||||
----------
|
----------
|
||||||
@ -30,6 +22,9 @@ UNDER WORK
|
|||||||
CHANGELOG
|
CHANGELOG
|
||||||
---------
|
---------
|
||||||
|
|
||||||
|
- Dry mode does not create target directories anymore
|
||||||
|
- Dry mode also tries mysqldumps now (check for error messages being logged)
|
||||||
|
- Added experimental partial download support
|
||||||
- Added Rsync exclude files suppport from osync
|
- Added Rsync exclude files suppport from osync
|
||||||
- Fixed another issue with existing symlinks to directories on target on non recursive backups
|
- Fixed another issue with existing symlinks to directories on target on non recursive backups
|
||||||
- Fixed remaining rsync -E option preventing obackup to work correctly on MacOS X
|
- Fixed remaining rsync -E option preventing obackup to work correctly on MacOS X
|
||||||
|
52
obackup.sh
52
obackup.sh
@ -5,7 +5,7 @@
|
|||||||
AUTHOR="(L) 2013-2014 by Orsiris \"Ozy\" de Jong"
|
AUTHOR="(L) 2013-2014 by Orsiris \"Ozy\" de Jong"
|
||||||
CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr"
|
CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr"
|
||||||
PROGRAM_VERSION=1.84preRC4
|
PROGRAM_VERSION=1.84preRC4
|
||||||
PROGRAM_BUILD=2411201402
|
PROGRAM_BUILD=2711201402
|
||||||
|
|
||||||
## type doesn't work on platforms other than linux (bash). If if doesn't work, always assume output is not a zero exitcode
|
## type doesn't work on platforms other than linux (bash). If if doesn't work, always assume output is not a zero exitcode
|
||||||
if ! type -p "$BASH" > /dev/null
|
if ! type -p "$BASH" > /dev/null
|
||||||
@ -50,6 +50,9 @@ else
|
|||||||
RUN_DIR=.
|
RUN_DIR=.
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
## Working directory for partial downloads
|
||||||
|
PARTIAL_DIR=".obackup_workdir_partial"
|
||||||
|
|
||||||
## Log a state message every $KEEP_LOGGING seconds. Should generally not be equal to soft or hard execution time so your log won't be unnecessary big.
|
## Log a state message every $KEEP_LOGGING seconds. Should generally not be equal to soft or hard execution time so your log won't be unnecessary big.
|
||||||
KEEP_LOGGING=1801
|
KEEP_LOGGING=1801
|
||||||
|
|
||||||
@ -220,7 +223,7 @@ function CleanUp
|
|||||||
|
|
||||||
function SendAlert
|
function SendAlert
|
||||||
{
|
{
|
||||||
eval "cat $LOG_FILE $COMPRESSION_PROGRAM > $ALERT_LOG_FILE"
|
eval "cat \"$LOG_FILE\" $COMPRESSION_PROGRAM > $ALERT_LOG_FILE"
|
||||||
MAIL_ALERT_MSG=$MAIL_ALERT_MSG$'\n\n'$(tail -n 25 "$LOG_FILE")
|
MAIL_ALERT_MSG=$MAIL_ALERT_MSG$'\n\n'$(tail -n 25 "$LOG_FILE")
|
||||||
if type -p mutt > /dev/null 2>&1
|
if type -p mutt > /dev/null 2>&1
|
||||||
then
|
then
|
||||||
@ -784,6 +787,7 @@ function BackupDatabase
|
|||||||
LogError "Connectivity test failed. Stopping current task."
|
LogError "Connectivity test failed. Stopping current task."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
dry_sql_cmd="$SSH_CMD mysqldump -u $SQL_USER --skip-lock-tables --single-transaction --database $1 > /dev/null 2>&1"
|
||||||
sql_cmd="$SSH_CMD mysqldump -u $SQL_USER --skip-lock-tables --single-transaction --database $1 $COMPRESSION_PROGRAM $COMPRESSION_OPTIONS > $LOCAL_SQL_STORAGE/$1.sql$COMPRESSION_EXTENSION"
|
sql_cmd="$SSH_CMD mysqldump -u $SQL_USER --skip-lock-tables --single-transaction --database $1 $COMPRESSION_PROGRAM $COMPRESSION_OPTIONS > $LOCAL_SQL_STORAGE/$1.sql$COMPRESSION_EXTENSION"
|
||||||
elif [ "$REMOTE_BACKUP" == "yes" ] && [ "$COMPRESSION_REMOTE" == "yes" ]
|
elif [ "$REMOTE_BACKUP" == "yes" ] && [ "$COMPRESSION_REMOTE" == "yes" ]
|
||||||
then
|
then
|
||||||
@ -793,8 +797,10 @@ function BackupDatabase
|
|||||||
LogError "Connectivity test failed. Stopping current task."
|
LogError "Connectivity test failed. Stopping current task."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
dry_sql_cmd="$SSH_CMD \"mysqldump -u $SQL_USER --skip-lock-tables --single-transaction --database $1 $COMPRESSION_PROGRAM $COMPRESSION_OPTIONS\" > /dev/null 2>&1"
|
||||||
sql_cmd="$SSH_CMD \"mysqldump -u $SQL_USER --skip-lock-tables --single-transaction --database $1 $COMPRESSION_PROGRAM $COMPRESSION_OPTIONS\" > $LOCAL_SQL_STORAGE/$1.sql$COMPRESSION_EXTENSION"
|
sql_cmd="$SSH_CMD \"mysqldump -u $SQL_USER --skip-lock-tables --single-transaction --database $1 $COMPRESSION_PROGRAM $COMPRESSION_OPTIONS\" > $LOCAL_SQL_STORAGE/$1.sql$COMPRESSION_EXTENSION"
|
||||||
else
|
else
|
||||||
|
dry_sql_cmd="mysqldump -u $SQL_USER --skip-lock-tables --single-transaction --database $1 $COMPRESSION_PROGRAM $COMPRESSION_OPTIONS > /dev/null 2>&1"
|
||||||
sql_cmd="mysqldump -u $SQL_USER --skip-lock-tables --single-transaction --database $1 $COMPRESSION_PROGRAM $COMPRESSION_OPTIONS > $LOCAL_SQL_STORAGE/$1.sql$COMPRESSION_EXTENSION"
|
sql_cmd="mysqldump -u $SQL_USER --skip-lock-tables --single-transaction --database $1 $COMPRESSION_PROGRAM $COMPRESSION_OPTIONS > $LOCAL_SQL_STORAGE/$1.sql$COMPRESSION_EXTENSION"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -802,7 +808,13 @@ function BackupDatabase
|
|||||||
then
|
then
|
||||||
Log "SQL_CMD: $sql_cmd"
|
Log "SQL_CMD: $sql_cmd"
|
||||||
fi
|
fi
|
||||||
eval "$sql_cmd 2>&1"
|
|
||||||
|
if [ $dryrun -ne 1 ]
|
||||||
|
then
|
||||||
|
eval "$sql_cmd 2>&1"
|
||||||
|
else
|
||||||
|
eval "$dry_sql_cmd"
|
||||||
|
fi
|
||||||
exit $?
|
exit $?
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1004,10 +1016,11 @@ function Rsync
|
|||||||
RSYNC_NO_RECURSE_ARGS=""
|
RSYNC_NO_RECURSE_ARGS=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $local_file_storage_path ]
|
# Directories should not be created here
|
||||||
then
|
#if [ ! -d $local_file_storage_path ]
|
||||||
mkdir -p "$local_file_storage_path"
|
#then
|
||||||
fi
|
# mkdir -p "$local_file_storage_path"
|
||||||
|
#fi
|
||||||
|
|
||||||
CheckConnectivity3rdPartyHosts
|
CheckConnectivity3rdPartyHosts
|
||||||
if [ "$REMOTE_BACKUP" == "yes" ]
|
if [ "$REMOTE_BACKUP" == "yes" ]
|
||||||
@ -1262,6 +1275,17 @@ function Init
|
|||||||
RSYNC_ARGS=$RSYNC_ARGS" --bwlimit=$BANDWIDTH"
|
RSYNC_ARGS=$RSYNC_ARGS" --bwlimit=$BANDWIDTH"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$PARTIAL" == "yes" ]
|
||||||
|
then
|
||||||
|
SYNC_OPTS=$SYNC_OPTS" --partial --partial-dir=\"$PARTIAL_DIR\""
|
||||||
|
RSYNC_EXCLUDE="$RSYNC_EXCLUDE --exclude=\"$PARTIAL_DIR\""
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $stats -eq 1 ]
|
||||||
|
then
|
||||||
|
SYNC_OPTS=$SYNC_OPTS" --stats"
|
||||||
|
fi
|
||||||
|
|
||||||
## Fix for symlink to directories on target can't get updated
|
## Fix for symlink to directories on target can't get updated
|
||||||
RSYNC_ARGS=$RSYNC_ARGS" --force"
|
RSYNC_ARGS=$RSYNC_ARGS" --force"
|
||||||
|
|
||||||
@ -1362,10 +1386,8 @@ function Main
|
|||||||
then
|
then
|
||||||
RotateBackups $LOCAL_SQL_STORAGE
|
RotateBackups $LOCAL_SQL_STORAGE
|
||||||
fi
|
fi
|
||||||
BackupDatabases
|
|
||||||
else
|
|
||||||
Log "DRYRUN: databases not backed up."
|
|
||||||
fi
|
fi
|
||||||
|
BackupDatabases
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$BACKUP_FILES" != "no" ]
|
if [ "$BACKUP_FILES" != "no" ]
|
||||||
@ -1398,6 +1420,8 @@ function Usage
|
|||||||
echo "--dry: will run obackup without actually doing anything, just testing"
|
echo "--dry: will run obackup without actually doing anything, just testing"
|
||||||
echo "--silent: will run obackup without any output to stdout, usefull for cron backups"
|
echo "--silent: will run obackup without any output to stdout, usefull for cron backups"
|
||||||
echo "--verbose: adds command outputs"
|
echo "--verbose: adds command outputs"
|
||||||
|
echo "--stats Adds rsync transfer statistics to verbose output"
|
||||||
|
echo "--partial Allows rsync to keep partial downloads that can be resumed later (experimental)"
|
||||||
echo "--no-maxtime: disables any soft and hard execution time checks"
|
echo "--no-maxtime: disables any soft and hard execution time checks"
|
||||||
exit 128
|
exit 128
|
||||||
}
|
}
|
||||||
@ -1412,6 +1436,8 @@ then
|
|||||||
else
|
else
|
||||||
verbose=0
|
verbose=0
|
||||||
fi
|
fi
|
||||||
|
stats=0
|
||||||
|
PARTIAL=0
|
||||||
# Alert flags
|
# Alert flags
|
||||||
soft_alert_total=0
|
soft_alert_total=0
|
||||||
error_alert=0
|
error_alert=0
|
||||||
@ -1433,6 +1459,12 @@ do
|
|||||||
--verbose)
|
--verbose)
|
||||||
verbose=1
|
verbose=1
|
||||||
;;
|
;;
|
||||||
|
--stats)
|
||||||
|
stats=1
|
||||||
|
;;
|
||||||
|
--partial)
|
||||||
|
PARTIAL="yes"
|
||||||
|
;;
|
||||||
--no-maxtime)
|
--no-maxtime)
|
||||||
no_maxtime=1
|
no_maxtime=1
|
||||||
;;
|
;;
|
||||||
|
Loading…
Reference in New Issue
Block a user