<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://tech.uvoo.io/index.php?action=history&amp;feed=atom&amp;title=PostgreSQL_Replication%2C_Redundancy_%26_Backup</id>
	<title>PostgreSQL Replication, Redundancy &amp; Backup - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://tech.uvoo.io/index.php?action=history&amp;feed=atom&amp;title=PostgreSQL_Replication%2C_Redundancy_%26_Backup"/>
	<link rel="alternate" type="text/html" href="https://tech.uvoo.io/index.php?title=PostgreSQL_Replication,_Redundancy_%26_Backup&amp;action=history"/>
	<updated>2026-05-10T15:54:25Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.2</generator>
	<entry>
		<id>https://tech.uvoo.io/index.php?title=PostgreSQL_Replication,_Redundancy_%26_Backup&amp;diff=207&amp;oldid=prev</id>
		<title>imported&gt;Busk at 14:27, 13 June 2019</title>
		<link rel="alternate" type="text/html" href="https://tech.uvoo.io/index.php?title=PostgreSQL_Replication,_Redundancy_%26_Backup&amp;diff=207&amp;oldid=prev"/>
		<updated>2019-06-13T14:27:55Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;# Common Command Examples in Postgres Logical Replication&lt;br /&gt;
&lt;br /&gt;
Good example and intro.&lt;br /&gt;
&lt;br /&gt;
https://www.digitalocean.com/community/tutorials/how-to-set-up-logical-replication-with-postgresql-10-on-ubuntu-18-04&lt;br /&gt;
&lt;br /&gt;
You only need the schema so use `pg_dump pdns --schema-only &amp;gt; pdns.sql` from master. Updates will have to be made on both on schema changes.&lt;br /&gt;
&lt;br /&gt;
Note that it works like traditional pub/sub where it will pull from queue. Use unique replication slots for different subscriptions if you want them all to be the same. &lt;br /&gt;
&lt;br /&gt;
## On publication host&lt;br /&gt;
```&lt;br /&gt;
echo &amp;quot;wal_level = logical&amp;quot; &amp;gt;&amp;gt; /etc/postgresql/10/main/postgresql.conf&lt;br /&gt;
&lt;br /&gt;
CREATE PUBLICATION pdns_slave WITH (publish = 'insert, update, delete');&lt;br /&gt;
ALTER PUBLICATION pdns_slave OWNER TO postgres;&lt;br /&gt;
ALTER PUBLICATION pdns_slave ADD TABLE ONLY public.cryptokeys;&lt;br /&gt;
ALTER PUBLICATION pdns_slave ADD TABLE ONLY public.domainmetadata;&lt;br /&gt;
ALTER PUBLICATION pdns_slave ADD TABLE ONLY public.domains;&lt;br /&gt;
ALTER PUBLICATION pdns_slave ADD TABLE ONLY public.records;&lt;br /&gt;
ALTER PUBLICATION pdns_slave ADD TABLE ONLY public.supermasters;&lt;br /&gt;
ALTER PUBLICATION pdns_slave ADD TABLE ONLY public.tsigkeys;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
select * from pg_publication;&lt;br /&gt;
select * from pg_replication_slots&lt;br /&gt;
```&lt;br /&gt;
&lt;br /&gt;
##Replication hosts&lt;br /&gt;
```&lt;br /&gt;
CREATE SUBSCRIPTION pdns_slave CONNECTION 'host=10.50.4.140 port=5432 user=replicator dbname=pdns' PUBLICATION pdns_slave WITH (connect = true, slot_name = 'pdns_ns1');^C&lt;br /&gt;
pdns=# drop subscription pdns_slave;&lt;br /&gt;
&lt;br /&gt;
select * from pg_subscription;&lt;br /&gt;
```&lt;br /&gt;
&lt;br /&gt;
If publisher ip address changes&lt;br /&gt;
```&lt;br /&gt;
update pg_subscription set subconninfo = 'host=10.50.4.144 port=5432 user=replicator dbname=pdns' where subdbid=17061;&lt;br /&gt;
```&lt;br /&gt;
&lt;br /&gt;
Clean-up If Needed&lt;br /&gt;
```&lt;br /&gt;
delete from pg_publication;&lt;br /&gt;
delete from pg_subscription;&lt;br /&gt;
&lt;br /&gt;
select pg_drop_replication_slot('pdns_ns1');&lt;br /&gt;
```&lt;br /&gt;
&lt;br /&gt;
https://www.postgresql.org/docs/10/logical-replication-subscription.html&lt;br /&gt;
https://www.digitalocean.com/community/tutorials/how-to-set-up-logical-replication-with-postgresql-10-on-ubuntu-18-04&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Replication Methods&lt;br /&gt;
&lt;br /&gt;
These can be really nice for redundancy and backups&lt;br /&gt;
&lt;br /&gt;
## Logical Replication&lt;br /&gt;
&lt;br /&gt;
This is new in 10. Has some nice advantages over streaming&lt;br /&gt;
&lt;br /&gt;
* https://www.postgresql.org/docs/11/logical-replication.html&lt;br /&gt;
* https://www.postgresql.org/docs/11/logical-replication-quick-setup.html&lt;br /&gt;
&lt;br /&gt;
## Streaming Replication&lt;br /&gt;
&lt;br /&gt;
* https://www.postgresql.org/docs/11/protocol-replication.html&lt;br /&gt;
&lt;br /&gt;
## Comparisions&lt;br /&gt;
&lt;br /&gt;
https://www.postgresql.org/docs/11/different-replication-solutions.html&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Backup&lt;br /&gt;
&lt;br /&gt;
You can do your full backups from one of your secondary replicated servers so it doesn't impact main database. Here are some methods. Choose the one that works best for your situation.&lt;br /&gt;
&lt;br /&gt;
* https://www.postgresql.org/docs/11/backup.html&lt;br /&gt;
&lt;br /&gt;
## Using filesystem&lt;br /&gt;
&lt;br /&gt;
You can always snap, send &amp;amp; clone your file system, like in zfs. Depending on situation, you probably want to shutdown database first to make sure it is quiesced to make sure you get a clean backup.&lt;br /&gt;
&lt;br /&gt;
### ZFS&lt;br /&gt;
&lt;br /&gt;
* https://blog.programster.org/send-and-receive-zfs-snapshots&lt;br /&gt;
* https://docs.oracle.com/cd/E18752_01/html/819-5461/gbchx.html&lt;br /&gt;
* https://www.howtoforge.com/tutorial/how-to-use-snapshots-clones-and-replication-in-zfs-on-linux/&lt;br /&gt;
* https://serverfault.com/questions/842531/how-to-perform-incremental-continuous-backups-of-zfs-pool&lt;br /&gt;
&lt;br /&gt;
# More Resources&lt;br /&gt;
&lt;br /&gt;
* https://medium.com/leboncoin-engineering-blog/managing-postgresql-backup-and-replication-for-very-large-databases-61fb36e815a0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Working with Logical Replication and Dropping subscriptions&lt;br /&gt;
&lt;br /&gt;
https://dba.stackexchange.com/questions/207653/cannot-drop-database-with-logical-replication&lt;br /&gt;
```&lt;br /&gt;
ALTER SUBSCRIPTION ... SET (slot_name = NONE).&lt;br /&gt;
```&lt;/div&gt;</summary>
		<author><name>imported&gt;Busk</name></author>
	</entry>
</feed>