Do not pass the password on the command line anymore to fix a warning
Since email notifications work now we do not want warnings. Write an option file with the credentials for mysqldump (https://dev.mysql.com/doc/refman/5.7/en/option-files.html)
This commit is contained in:
parent
7073e5d574
commit
ffc6858dcc
@ -63,18 +63,22 @@ mysql_client 'default' do
|
|||||||
not_if { node["backup"]["mysql"]["databases"].empty? }
|
not_if { node["backup"]["mysql"]["databases"].empty? }
|
||||||
end
|
end
|
||||||
|
|
||||||
include_recipe 'logrotate'
|
# Write the credentials file to allow dumps without password for the root
|
||||||
unless node["backup"]["mysql"]["databases"].empty?
|
# user (https://dev.mysql.com/doc/refman/5.7/en/option-files.html)
|
||||||
# Install MySQL client (includes mysqldump)
|
file "/root/.my.cnf" do
|
||||||
mysql_client 'default' do
|
mode "600"
|
||||||
action :create
|
content lazy { <<-EOF
|
||||||
end
|
[client]
|
||||||
end
|
user=#{node["backup"]["mysql"]["username"]}
|
||||||
|
password=#{node["backup"]["mysql"]["password"]}
|
||||||
logrotate_app 'backup' do
|
EOF
|
||||||
path '/var/log/backup.log'
|
}
|
||||||
frequency 'daily'
|
not_if { node["backup"]["mysql"]["password"].nil? }
|
||||||
rotate 10
|
end
|
||||||
create '640 root root'
|
|
||||||
end
|
logrotate_app 'backup' do
|
||||||
|
path '/var/log/backup.log'
|
||||||
|
frequency 'daily'
|
||||||
|
rotate 10
|
||||||
|
create '640 root root'
|
||||||
end
|
end
|
||||||
|
@ -40,7 +40,6 @@ end
|
|||||||
Database::MySQL.defaults do |db|
|
Database::MySQL.defaults do |db|
|
||||||
db.host = "<%= node["backup"]["mysql"]["host"] %>"
|
db.host = "<%= node["backup"]["mysql"]["host"] %>"
|
||||||
db.username = "<%= node["backup"]["mysql"]["username"] %>"
|
db.username = "<%= node["backup"]["mysql"]["username"] %>"
|
||||||
db.password = "<%= node["backup"]["mysql"]["password"] %>"
|
|
||||||
db.additional_options = ['--quick', '--single-transaction']
|
db.additional_options = ['--quick', '--single-transaction']
|
||||||
end
|
end
|
||||||
<%- end -%>
|
<%- end -%>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user