Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Fjen Undso
myftpdumper
Commits
6dfb4b19
Commit
6dfb4b19
authored
May 10, 2017
by
Fjen Undso
Browse files
fix ftp mkdir for noninteractive shells
parent
afd837b7
Changes
1
Hide whitespace changes
Inline
Side-by-side
myftpdumper.sh
View file @
6dfb4b19
...
...
@@ -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"
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment