From 055b450d738ce13ed66dcecda42279dd26ca7913 Mon Sep 17 00:00:00 2001 From: abednarik Date: Fri, 6 Nov 2015 15:28:56 -0300 Subject: [PATCH] (MODULES-2605) Use MYSQL_PWD to avoid mysqldump warnings. Instead of using password as a command arguments, we are setting MYSQL_ENV variable. See https://dev.mysql.com/doc/refman/5.1/en/password-security-user.html --- templates/mysqlbackup.sh.erb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/templates/mysqlbackup.sh.erb b/templates/mysqlbackup.sh.erb index a2fb4e7..250e394 100755 --- a/templates/mysqlbackup.sh.erb +++ b/templates/mysqlbackup.sh.erb @@ -19,6 +19,9 @@ PASS='<%= @backuppassword %>' DIR=<%= @backupdir %> ROTATE=<%= [ Integer(@backuprotate) - 1, 0 ].max %> +# Set MYSQL_PWD env variable. See https://dev.mysql.com/doc/refman/5.1/en/password-security-user.html +export MYSQL_PWD="$PASS" + PREFIX=mysql_backup_ <% if @ignore_events %> ADDITIONAL_OPTIONS="--ignore-table=mysql.event" @@ -61,20 +64,20 @@ cleanup <% end -%> <% if @backupdatabases.empty? -%> <% if @file_per_database -%> -mysql -u${USER} -p${PASS} -s -r -N -e 'SHOW DATABASES' | while read dbname +mysql -u${USER} -s -r -N -e 'SHOW DATABASES' | while read dbname do - mysqldump -u${USER} -p${PASS} --opt --flush-logs --single-transaction \ + mysqldump -u${USER} --opt --flush-logs --single-transaction \ ${ADDITIONAL_OPTIONS} \ ${dbname} <% if @backupcompress %>| bzcat -zc <% end %>> ${DIR}/${PREFIX}${dbname}_`date +%Y%m%d-%H%M%S`.sql<% if @backupcompress %>.bz2<% end %> done <% else -%> -mysqldump -u${USER} -p${PASS} --opt --flush-logs --single-transaction \ +mysqldump -u${USER} --opt --flush-logs --single-transaction \ ${ADDITIONAL_OPTIONS} \ --all-databases <% if @backupcompress %>| bzcat -zc <% end %>> ${DIR}/${PREFIX}`date +%Y%m%d-%H%M%S`.sql<% if @backupcompress %>.bz2<% end %> <% end -%> <% else -%> <% @backupdatabases.each do |db| -%> -mysqldump -u${USER} -p${PASS} --opt --flush-logs --single-transaction \ +mysqldump -u${USER} --opt --flush-logs --single-transaction \ ${ADDITIONAL_OPTIONS} \ <%= db %><% if @backupcompress %>| bzcat -zc <% end %>> ${DIR}/${PREFIX}<%= db %>_`date +%Y%m%d-%H%M%S`.sql<% if @backupcompress %>.bz2<% end %> <% end -%> @@ -91,3 +94,6 @@ fi <%= script %> <%- end -%> <% end -%> + +# Unset MYSQL_PWD env variable +unset MYSQL_PWD