Fix missing Mastodon/PosgreSQL backups
The backup cookbook was incomplete, and also there was no database configured to be backed up.
This commit is contained in:
parent
214e69427e
commit
4bccf4dd88
|
@ -26,6 +26,11 @@ set_unless["backup"]["mysql"]["databases"] = []
|
||||||
set_unless["backup"]["mysql"]["username"] = "root"
|
set_unless["backup"]["mysql"]["username"] = "root"
|
||||||
set_unless["backup"]["mysql"]["host"] = "localhost"
|
set_unless["backup"]["mysql"]["host"] = "localhost"
|
||||||
|
|
||||||
|
# PostgreSQL default settings
|
||||||
|
set_unless["backup"]["postgresql"]["databases"] = []
|
||||||
|
set_unless["backup"]["postgresql"]["host"] = "localhost"
|
||||||
|
set_unless["backup"]["postgresql"]["port"] = 5432
|
||||||
|
|
||||||
# Redis default settings
|
# Redis default settings
|
||||||
set_unless["backup"]["redis"]["databases"] = []
|
set_unless["backup"]["redis"]["databases"] = []
|
||||||
set_unless["backup"]["redis"]["host"] = "localhost"
|
set_unless["backup"]["redis"]["host"] = "localhost"
|
||||||
|
|
|
@ -17,7 +17,11 @@ KosmosBackup.new(:default, 'default backup') do
|
||||||
<%- end -%>
|
<%- end -%>
|
||||||
|
|
||||||
<%- if node["backup"]["postgresql"] -%>
|
<%- if node["backup"]["postgresql"] -%>
|
||||||
database PostgreSQL
|
<%- node["backup"]["postgresql"]["databases"].each do |db_name| -%>
|
||||||
|
database PostgreSQL, :"<%= db_name.to_sym %>" do |db|
|
||||||
|
db.name = "<%= db_name %>"
|
||||||
|
end
|
||||||
|
<%- end -%>
|
||||||
<%- end -%>
|
<%- end -%>
|
||||||
|
|
||||||
<%- if node["mongodb"] -%>
|
<%- if node["mongodb"] -%>
|
||||||
|
|
|
@ -45,15 +45,7 @@ Database::MySQL.defaults do |db|
|
||||||
end
|
end
|
||||||
<%- end -%>
|
<%- end -%>
|
||||||
|
|
||||||
<%- if node["backup"]["mysql"] -%>
|
<%- if node["backup"]["redis"] -%>
|
||||||
Database::MySQL.defaults do |db|
|
|
||||||
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 -%>
|
|
||||||
|
|
||||||
Database::Redis.defaults do |db|
|
Database::Redis.defaults do |db|
|
||||||
db.host = "<%= node["backup"]["redis"]["host"] %>"
|
db.host = "<%= node["backup"]["redis"]["host"] %>"
|
||||||
db.port = 6379
|
db.port = 6379
|
||||||
|
@ -61,13 +53,14 @@ Database::Redis.defaults do |db|
|
||||||
<%# db.password = "my_password"%>
|
<%# db.password = "my_password"%>
|
||||||
<%# db.socket = "/tmp/redis.sock"%>
|
<%# db.socket = "/tmp/redis.sock"%>
|
||||||
end
|
end
|
||||||
|
<%- end -%>
|
||||||
|
|
||||||
<%- if node["backup"]["postgresql"] -%>
|
<%- if node["backup"]["postgresql"] -%>
|
||||||
Database::PostgreSQL.defaults do |db|
|
Database::PostgreSQL.defaults do |db|
|
||||||
db.username = "<%= node["backup"]["postgresql"]["username"] %>"
|
db.username = "<%= node["backup"]["postgresql"]["username"] %>"
|
||||||
db.password = "<%= node["backup"]["postgresql"]["password"] %>"
|
db.password = "<%= node["backup"]["postgresql"]["password"] %>"
|
||||||
db.host = "<%= node["backup"]["postgresql"]["host"] %>"
|
db.host = "<%= node["backup"]["postgresql"]["host"] %>"
|
||||||
db.port = 5432
|
db.port = "<%= node["backup"]["postgresql"]["port"] %>"
|
||||||
# db.socket = "/var/run/postgresql/.s.PGSQL.5432"
|
# db.socket = "/var/run/postgresql/.s.PGSQL.5432"
|
||||||
# When dumping all databases, `skip_tables` and `only_tables` are ignored.
|
# When dumping all databases, `skip_tables` and `only_tables` are ignored.
|
||||||
db.skip_tables = []
|
db.skip_tables = []
|
||||||
|
|
|
@ -180,10 +180,18 @@ application mastodon_path do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
# Backup
|
||||||
|
#
|
||||||
|
|
||||||
unless node.chef_environment == "development"
|
unless node.chef_environment == "development"
|
||||||
# Backup the database to S3
|
|
||||||
node.override["backup"]["postgresql"]["host"] = "localhost"
|
node.override["backup"]["postgresql"]["host"] = "localhost"
|
||||||
node.override["backup"]["postgresql"]["username"] = "postgres"
|
node.override["backup"]["postgresql"]["username"] = "postgres"
|
||||||
node.override["backup"]["postgresql"]["password"] = node['postgresql']['password']['postgres']
|
node.override["backup"]["postgresql"]["password"] = node['postgresql']['password']['postgres']
|
||||||
|
unless node["backup"]["postgresql"]["databases"].include? 'mastodon'
|
||||||
|
node.override["backup"]["postgresql"]["databases"] =
|
||||||
|
node["backup"]["postgresql"]["databases"].to_a << "mastodon"
|
||||||
|
end
|
||||||
|
|
||||||
include_recipe "backup"
|
include_recipe "backup"
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue