Commit 847ccca6 authored by Sven Greiner's avatar Sven Greiner
Browse files

More fixes

parent 12b28ddc
......@@ -5,9 +5,6 @@
#
# Backup all available MySQL databases via mydumper and optionally upload them
# to an (s)ftp server. Backups can be compressed and encrypted.
#
# sftp note: ssh private/public key with no password is required if pwauth is
# not used.
################################################################################
......@@ -20,7 +17,7 @@
declare -r BACKUP_PATH=""
# Send mail to this address in case of any errors. No mail if empty.
declare -r ADMINMAIL=
declare -r ADMINMAIL=""
# Keep so many backups or all if 0
declare -r NUMBACKUPS=30
......@@ -48,12 +45,12 @@ declare -r DB_EXCLUDE='^(?!(mysql|phpmyadmin|information_schema|performance_sche
# Type of ftp connection: ftp, ftps, sftp
# Leave empty to disable upload
declare -r FTP_TYPE=
declare -r FTP_TYPE=""
declare -r FTP_HOST=""
declare -r FTP_USER=""
declare -r FTP_PASS=""
declare -r FTP_PORT= # empty for default
declare -r FTP_PASS="" # if empty, ssh key with no password is required
declare -r FTP_PORT="" # empty for default
declare -r FTP_DIR=""
declare -r FTP_NUMBACKUPS=90
......@@ -63,8 +60,8 @@ declare -r FTP_NUMBACKUPS=90
# GPG key ID used for encryption starting with "0x" (preferred)
# or passphrase for symmetric encryption or empty (no encryption).
declare -r GPG_KEYID=
declare -r GPG_PASS=
declare -r GPG_KEYID=""
declare -r GPG_PASS=""
################################################################################
......@@ -153,8 +150,10 @@ check_prerequisites() {
require_command "lftp"
[[ -z "$FTP_HOST" ]] && error "FTP_HOST not set"
[[ -z "$FTP_USER" ]] && error "FTP_USER not set"
[[ -z "$FTP_PASS" ]] && error "FTP_PASS not set"
[[ -z "$FTP_DIR" ]] && error "FTP_DIR not set"
[[ "$FTP_TYPE" != "sftp" ]] \
&& [[ -z "$FTP_PASS" ]] \
&& error "FTP_PASS not set and not using sftp with ssh key"
fi
}
......@@ -268,14 +267,14 @@ exec_ftp() {
upload() {
if wants_upload; then
# FTP: directory permission check
ftpmkdir=$(exec_ftp "mkdir -p $FTP_DIR/$date; exit")
ftpmkdir=$(exec_ftp "mkdir -p \"$FTP_DIR/$date\"; exit")
if [[ "$ftpmkdir" != *"mkdir OK"* ]]; then
error "Failed create \"$FTP_DIR/$date\" on remote server"
fi
# FTP: delete old backups
info "Delete old backups on FTP..."
ftpfiles=$(exec_ftp "cd $FTP_DIR; nlist; exit")
ftpfiles=$(exec_ftp "cd \"$FTP_DIR\"; nlist; exit")
# filter files starting with a dot
ftpfiles=( $(echo $ftpfiles | sed 's,\.[A-Za-z0-9_\/\.]* , ,g') )
# find old backups
......@@ -287,11 +286,11 @@ upload() {
# delete on ftp
[[ ${#ftpfilesdelete[@]} -ge 1 ]] \
&& ftpfilesdelete=${ftpfilesdelete[@]} \
&& exec_ftp "cd $FTP_DIR; rm -r $ftpfilesdelete; exit"
&& exec_ftp "cd \"$FTP_DIR\"; rm -r $ftpfilesdelete; exit"
# FTP: upload
info "Upload to FTP..."
exec_ftp "cd $FTP_DIR; mirror -R $backupdir; exit"
exec_ftp "cd \"$FTP_DIR\"; mirror -R \"$backupdir\"; exit"
fi
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment