migration: Add PostgreSQL server migration script
This script captures the steps taken to migrate from the PostgreSQL server in the Kubernetes cluster, managed by _postgres operator_, to the dedicated server on _db0.pyrocufflink.blue_. The data were restored from the backups created by _wal-e_, and then the new server was promoted to primary. Finally, I cleaned up the roles and databases that are no longer needed.frigate-exporter
parent
4f202c55e4
commit
afb7030e44
|
@ -0,0 +1,48 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
server=db0.pyrocufflink.blue
|
||||||
|
sudo='sudo'
|
||||||
|
sudo_postgres='sudo -u postgres'
|
||||||
|
#server=root@db1.local
|
||||||
|
#sudo=''
|
||||||
|
#sudo_postgres='runuser -u postgres --'
|
||||||
|
|
||||||
|
ssh ${server} ${sudo_postgres} pg_ctl promote -D /etc/postgresql -w -t 300
|
||||||
|
ssh ${server} ${sudo_postgres} psql <<EOF
|
||||||
|
ALTER USER "authelia.authelia" RENAME TO authelia;
|
||||||
|
ALTER USER "firefly-iii.firefly" RENAME TO firefly;
|
||||||
|
ALTER USER "home-assistant.homeassistant" RENAME TO homeassistant;
|
||||||
|
|
||||||
|
ALTER DATABASE authelia REFRESH COLLATION VERSION;
|
||||||
|
ALTER DATABASE firefly REFRESH COLLATION VERSION;
|
||||||
|
ALTER DATABASE homeassistant REFRESH COLLATION VERSION;
|
||||||
|
ALTER DATABASE postgres REFRESH COLLATION VERSION;
|
||||||
|
ALTER DATABASE template0 REFRESH COLLATION VERSION;
|
||||||
|
ALTER DATABASE template1 REFRESH COLLATION VERSION;
|
||||||
|
|
||||||
|
DROP DATABASE dustin;
|
||||||
|
DROP DATABASE wger;
|
||||||
|
|
||||||
|
DROP OWNED BY admin;
|
||||||
|
DROP OWNED BY cron_admin;
|
||||||
|
DROP OWNED BY robot_zmon;
|
||||||
|
\c authelia
|
||||||
|
DROP OWNED BY admin;
|
||||||
|
DROP OWNED BY robot_zmon;
|
||||||
|
\c firefly
|
||||||
|
DROP OWNED BY admin;
|
||||||
|
DROP OWNED BY robot_zmon;
|
||||||
|
\c homeassistant
|
||||||
|
DROP OWNED BY admin;
|
||||||
|
DROP OWNED BY robot_zmon;
|
||||||
|
\c template1
|
||||||
|
DROP OWNED BY admin;
|
||||||
|
DROP OWNED BY robot_zmon;
|
||||||
|
DROP ROLE admin;
|
||||||
|
DROP ROLE cron_admin;
|
||||||
|
DROP ROLE dustin;
|
||||||
|
DROP ROLE standby;
|
||||||
|
DROP ROLE "wger.wger";
|
||||||
|
DROP ROLE zalandos;
|
||||||
|
DROP ROLE robot_zmon;
|
||||||
|
EOF
|
Loading…
Reference in New Issue