Add support for PostgreSQL backups
This commit is contained in:
parent
d49f28574c
commit
4e5d452aff
@ -58,6 +58,12 @@ if node["backup"]["default_model"]
|
||||
end
|
||||
|
||||
include_recipe 'logrotate'
|
||||
if node["backup"]["mysql"]
|
||||
# Install MySQL client (includes mysqldump)
|
||||
mysql_client 'default' do
|
||||
action :create
|
||||
end
|
||||
end
|
||||
|
||||
logrotate_app 'backup' do
|
||||
path '/var/log/backup.log'
|
||||
|
@ -16,6 +16,10 @@ KosmosBackup.new(:default, 'default backup') do
|
||||
<%- end -%>
|
||||
<%- end -%>
|
||||
|
||||
<%- if node["backup"]["postgresql"] -%>
|
||||
database PostgreSQL
|
||||
<%- end -%>
|
||||
|
||||
<%- if node["mongodb"] -%>
|
||||
<%- node["backup"]["mongodb"]["databases"].each do |db_name| -%>
|
||||
database MongoDB, :"<%= db_name.to_sym %>" do |db|
|
||||
|
@ -45,11 +45,11 @@ Database::MySQL.defaults do |db|
|
||||
end
|
||||
<%- end -%>
|
||||
|
||||
<%- if node["backup"]["postgresql"] -%>
|
||||
<%- if node["backup"]["mysql"] -%>
|
||||
Database::MySQL.defaults do |db|
|
||||
db.host = "<%= node["backup"]["postgresql"]["host"] %>"
|
||||
db.username = "<%= node["backup"]["postgresql"]["username"] %>"
|
||||
db.password = "<%= node["backup"]["postgresql"]["password"] %>"
|
||||
db.host = "<%= node["backup"]["mysql"]["host"] %>"
|
||||
db.username = "<%= node["backup"]["mysql"]["username"] %>"
|
||||
db.password = "<%= node["backup"]["mysql"]["password"] %>"
|
||||
db.additional_options = ['--quick', '--single-transaction']
|
||||
end
|
||||
<%- end -%>
|
||||
@ -63,15 +63,15 @@ Database::Redis.defaults do |db|
|
||||
end
|
||||
|
||||
<%- if node["backup"]["postgresql"] -%>
|
||||
database PostgreSQL do |db|
|
||||
db.username = ""
|
||||
db.password = "<%= node['postgresql']['password']['postgres'] %>"
|
||||
db.host = "localhost"
|
||||
Database::PostgreSQL.defaults do |db|
|
||||
db.username = "<%= node["backup"]["postgresql"]["username"] %>"
|
||||
db.password = "<%= node["backup"]["postgresql"]["password"] %>"
|
||||
db.host = "<%= node["backup"]["postgresql"]["host"] %>"
|
||||
db.port = 5432
|
||||
db.socket = "/tmp/pg.sock"
|
||||
# db.socket = "/var/run/postgresql/.s.PGSQL.5432"
|
||||
# When dumping all databases, `skip_tables` and `only_tables` are ignored.
|
||||
db.skip_tables = ['skip', 'these', 'tables']
|
||||
db.only_tables = ['only', 'these' 'tables']
|
||||
db.skip_tables = []
|
||||
db.only_tables = []
|
||||
db.additional_options = []
|
||||
end
|
||||
<% end -%>
|
||||
|
Loading…
x
Reference in New Issue
Block a user