WIP Prepare postgres for migration by replication
This commit is contained in:
121
site-cookbooks/kosmos_postgresql/recipes/management_scripts.rb
Normal file
121
site-cookbooks/kosmos_postgresql/recipes/management_scripts.rb
Normal file
@@ -0,0 +1,121 @@
|
||||
#
|
||||
# Cookbook:: kosmos_postgresql
|
||||
# Recipe:: management_scripts
|
||||
#
|
||||
|
||||
credentials = data_bag_item('credentials', 'postgresql')
|
||||
|
||||
cookbook_file "/usr/local/bin/pg_dump_all_databases" do
|
||||
source "dump_all_databases.sh"
|
||||
user "postgres"
|
||||
group "postgres"
|
||||
mode "0744"
|
||||
end
|
||||
|
||||
cookbook_file "/usr/local/bin/pg_dump_database" do
|
||||
source "dump_database.sh"
|
||||
user "postgres"
|
||||
group "postgres"
|
||||
mode "0744"
|
||||
end
|
||||
|
||||
cookbook_file "/usr/local/bin/pg_restore_all_databases" do
|
||||
source "restore_all_databases.sh"
|
||||
user "postgres"
|
||||
group "postgres"
|
||||
mode "0744"
|
||||
end
|
||||
|
||||
cookbook_file "/usr/local/bin/pg_restore_database" do
|
||||
source "restore_database.sh"
|
||||
user "postgres"
|
||||
group "postgres"
|
||||
mode "0744"
|
||||
end
|
||||
|
||||
cookbook_file "/usr/local/bin/pg_create_replication_publications" do
|
||||
source "create_publications.sh"
|
||||
user "postgres"
|
||||
group "postgres"
|
||||
mode "0744"
|
||||
end
|
||||
|
||||
cookbook_file "/usr/local/bin/pg_create_replication_publication" do
|
||||
source "create_publication.sh"
|
||||
user "postgres"
|
||||
group "postgres"
|
||||
mode "0744"
|
||||
end
|
||||
|
||||
cookbook_file "/usr/local/bin/pg_drop_replication_publications" do
|
||||
source "drop_publications.sh"
|
||||
user "postgres"
|
||||
group "postgres"
|
||||
mode "0744"
|
||||
end
|
||||
|
||||
cookbook_file "/usr/local/bin/pg_list_replication_publications" do
|
||||
source "list_publications.sh"
|
||||
user "postgres"
|
||||
group "postgres"
|
||||
mode "0744"
|
||||
end
|
||||
|
||||
cookbook_file "/usr/local/bin/pg_list_replication_slots" do
|
||||
source "list_replication_slots.sh"
|
||||
user "postgres"
|
||||
group "postgres"
|
||||
mode "0744"
|
||||
end
|
||||
|
||||
template "/usr/local/bin/pg_create_replication_subscriptions" do
|
||||
source "create_subscriptions.sh.erb"
|
||||
user "postgres"
|
||||
group "postgres"
|
||||
mode "0740"
|
||||
variables pg_host: "pg.kosmos.local",
|
||||
pg_port: 5432,
|
||||
pg_user: "replication",
|
||||
pg_pass: credentials["replication_password"]
|
||||
sensitive true
|
||||
end
|
||||
|
||||
template "/usr/local/bin/pg_create_replication_subscription" do
|
||||
source "create_subscription.sh.erb"
|
||||
user "postgres"
|
||||
group "postgres"
|
||||
mode "0740"
|
||||
variables pg_host: "pg.kosmos.local",
|
||||
pg_port: 5432,
|
||||
pg_user: "replication",
|
||||
pg_pass: credentials["replication_password"]
|
||||
sensitive true
|
||||
end
|
||||
|
||||
cookbook_file "/usr/local/bin/pg_drop_replication_subscriptions" do
|
||||
source "drop_subscriptions.sh"
|
||||
user "postgres"
|
||||
group "postgres"
|
||||
mode "0744"
|
||||
end
|
||||
|
||||
cookbook_file "/usr/local/bin/pg_list_replication_subscriptions" do
|
||||
source "list_subscriptions.sh"
|
||||
user "postgres"
|
||||
group "postgres"
|
||||
mode "0744"
|
||||
end
|
||||
|
||||
cookbook_file "/usr/local/bin/pg_fix_sequences_in_all_databases" do
|
||||
source "fix_sequences.sh"
|
||||
user "postgres"
|
||||
group "postgres"
|
||||
mode "0744"
|
||||
end
|
||||
|
||||
cookbook_file "/usr/local/bin/pg_fix_sequences" do
|
||||
source "fix_sequences.sh"
|
||||
user "postgres"
|
||||
group "postgres"
|
||||
mode "0744"
|
||||
end
|
||||
Reference in New Issue
Block a user