Skip to content

Commit

Permalink
Escaping
Browse files Browse the repository at this point in the history
  • Loading branch information
Ed Akerboom committed Dec 11, 2018
1 parent fd2c6e8 commit 7799416
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions bin/drivers/mysql/connectors/ssh/save
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ bin=$(dirname "$(python -c 'import os,sys;print(os.path.realpath(sys.argv[1]+"/.

file=$3

options="--opt -B --add-drop-database"
connection_details="--defaults-extra-file=${connection_config}"

where=$(cat "${ssh_config}")
_user=$(cat "${connection_config}" | grep "^user" | cut -d '=' -f 2 | xargs)
_pass=$(cat "${connection_config}" | grep "^password" | cut -d '=' -f 2 | xargs)
_host=$(cat "${connection_config}" | grep "^host" | cut -d '=' -f 2 | xargs)
_user=$(printf %q $(cat "${connection_config}" | grep "^user" | cut -d '=' -f 2 | xargs))
_pass=$(printf %q $(cat "${connection_config}" | grep "^password" | cut -d '=' -f 2 | xargs))
_host=$(printf %q $(cat "${connection_config}" | grep "^host" | cut -d '=' -f 2 | xargs))

cmd="mysqldump --opt -B --add-drop-database --skip-extended-insert --user='${_user}' --host='${_host}' --password='${_pass}' ${database} | gzip"
escape_commandline "${cmd}"

ssh ${where} "nice -n 19 sh -c '${escaped}'" > "${file}"

ssh ${where} "nice -n 19 sh -c 'mysqldump ${options} --user=\"${_user}\" --host=\"${_host}\" --password=\"${_pass}\" ${database} | gzip'" > "${file}"
exit $?

0 comments on commit 7799416

Please sign in to comment.