Commit 6dfb4b19 authored by Fjen Undso's avatar Fjen Undso
Browse files

fix ftp mkdir for noninteractive shells

parent afd837b7
......@@ -63,7 +63,7 @@ error() {
echo "ERROR: $1" >&2
if wants_mail && [[ -z "$2" ]]; then
mail -s "MySQL BACKUP FAILED" "$ADMINMAIL" <<- EOF
mail -s "MySQL BACKUP FAILED" "$ADMINMAIL" <<-EOF
Date: $(date --rfc-3339=seconds)
Hostname: $(hostname)
Failed with message: $1
......@@ -250,24 +250,21 @@ exec_ftp() {
upload() {
if wants_upload; then
# FTP: directory permission check
# FTP: directory creation
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")
# filter files starting with a dot
## filter files starting with a dot
ftpfiles=( $(echo $ftpfiles | sed 's,\.[A-Za-z0-9_\/\.]* , ,g') )
# find old backups
## find old backups
ftpfilesdelete=()
while [[ ${#ftpfiles[@]} -ge $FTP_NUMBACKUPS ]]; do
ftpfilesdelete+=(${ftpfiles[0]})
ftpfiles=("${ftpfiles[@]:1}")
done
# delete on ftp
## delete on ftp
[[ ${#ftpfilesdelete[@]} -ge 1 ]] \
&& ftpfilesdelete=${ftpfilesdelete[@]} \
&& exec_ftp "cd \"$FTP_DIR\"; rm -r $ftpfilesdelete; exit"
......
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