diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2009-05-05 04:30:07 +0200 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2009-05-05 04:30:07 +0200 |
commit | 44bd0a8c1a8cdb4ac03b7d394c30d8a76ecc2603 (patch) | |
tree | a99bec5df20157bd0525e8ecc4a6e0546e466658 | |
parent | 126b3925bb7bcda1032d7c6df38788f992b8e9db (diff) | |
download | backup-44bd0a8c1a8cdb4ac03b7d394c30d8a76ecc2603.tar.gz backup-44bd0a8c1a8cdb4ac03b7d394c30d8a76ecc2603.tar.xz backup-44bd0a8c1a8cdb4ac03b7d394c30d8a76ecc2603.zip |
feature: selfupdating
-rwxr-xr-x | mysql/mysql_backup.sh | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/mysql/mysql_backup.sh b/mysql/mysql_backup.sh index 43e997b..48f41a7 100755 --- a/mysql/mysql_backup.sh +++ b/mysql/mysql_backup.sh @@ -26,11 +26,12 @@ TMP_DIRECTORY="/tmp" # backup name BACKUP_PREFIX="$(hostname -f)_${MYSQL_SERVER}_$(date +%F)" -# logging +# logging (0 = enabled, all other = disabled) LOGGING="0" ## end of configuration +# only output something if logging is enabled log() { if [ $LOGGING -eq 0 ]; then if [ -n "$1" ]; then @@ -41,8 +42,26 @@ log() { fi } +# selfupdate magic +_self_update() { + pushd $(dirname $0) &>/dev/null + + git fetch origin 2>/dev/null + if [[ -n "$(git whatchanged HEAD..origin/master)" ]]; then + echo "Selfupdating backupscript..." | log + git merge origin/master | log + echo "Selfupdating done." | log + echo | log + + popd &>/dev/null + exec $0 + fi + + popd &>/dev/null +} + # check for tools -for prog in mysqlshow mysqldump ncftpput +for prog in git mysqlshow mysqldump ncftpput do if ! hash $prog 2>/dev/null ; then echo "Error: This script needs: $prog. Exiting..." >&2 @@ -50,6 +69,8 @@ do fi done +_self_update() + echo "Started backup of mysql databases ($(date +%c)):" | log echo | log |