{"id":20145,"date":"2022-10-27T18:30:00","date_gmt":"2022-10-27T16:30:00","guid":{"rendered":"https:\/\/www.dbi-services.com\/blog\/?p=20145"},"modified":"2022-10-27T18:30:00","modified_gmt":"2022-10-27T16:30:00","slug":"bootstrap-patroni-cluster-from-pgbackrest-backup","status":"publish","type":"post","link":"https:\/\/www.dbi-services.com\/blog\/bootstrap-patroni-cluster-from-pgbackrest-backup\/","title":{"rendered":"Bootstrap Patroni Cluster from pgBackRest Backup"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">While preparing myself for the pgconf.eu in Berlin this week I made a lot of research regarding Patroni and pgBackRest. I was aware that it&#8217;s possible to recreate a replica from a pgBackRest backup. But I was also wondering, what happens if the complete Patroni Cluster is gone. I know this is not the most common case, but never say never. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-starting-point\">Starting point<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s assume we have\/had a running Patroni Cluster on three nodes, using etcd as Key Value Store. Everything was working fine.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>postgres@hero3:\/home\/postgres\/ &#091;PG1] patronictl list\n+--------+----------------+---------+---------+----+-----------+\n| Member | Host | Role | State | TL | Lag in MB |\nCluster: PG1 (7157976722952275157) ---------+----+-----------+\n| hero1 | 192.168.22.251 | Replica | running | 6 | 0 |\n| hero2 | 192.168.22.252 | Leader | running | 6 | |\n| hero3 | 192.168.22.253 | Replica | running | 6 | 0 |\n+--------+----------------+---------+---------+----+-----------+<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The cluster is using pgBackRest to create backups and there are also backups available for this cluster.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>postgres@backup_hero:\/home\/postgres\/ &#091;pg14] pgbackrest --stanza=hero2hero info\nstanza: hero2hero\n    status: ok\n    cipher: none\n\n    db (current)\n        wal archive min\/max (14): 000000010000000000000001\/00000007000000000000001D\n\n        full backup: 20221024-094106F\n            timestamp start\/stop: 2022-10-24 09:41:06 \/ 2022-10-24 09:42:15\n            wal start\/stop: 00000001000000000000000B \/ 00000001000000000000000D\n            database size: 105MB, database backup size: 105MB\n            repo1: backup set size: 30.8MB, backup size: 30.8MB\n\n        full backup: 20221024-094900F\n            timestamp start\/stop: 2022-10-24 09:49:00 \/ 2022-10-24 09:49:11\n            wal start\/stop: 000000010000000000000011 \/ 000000010000000000000011\n            database size: 105MB, database backup size: 105MB\n            repo1: backup set size: 30.8MB, backup size: 30.8MB\n\n        full backup: 20221024-145020F\n            timestamp start\/stop: 2022-10-24 14:50:20 \/ 2022-10-24 14:50:34\n            wal start\/stop: 000000050000000000000018 \/ 000000050000000000000018\n            database size: 105.2MB, database backup size: 105.2MB\n            repo1: backup set size: 30.8MB, backup size: 30.8MB\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Due to a mistake the PGDATA directory was deleted on all three nodes. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>postgres@hero1:\/u02\/pgdata\/14\/PG1\/ &#091;PG1] ls -al\ntotal 0\ndrwx------. 2 postgres postgres 6 Oct 24 15:28 .\ndrwxr-x---. 3 postgres postgres 17 Sep 5 10:20 ..\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">To have a clear cut, we stop the Patroni Service on all three nodes.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>postgres@hero3:\/u02\/pgdata\/14\/PG1\/ &#091;PG1] sudo systemctl stop patroni\npostgres@hero3:\/u02\/pgdata\/14\/PG1\/ &#091;PG1] sudo systemctl status patroni\n\u25cf patroni.service - dbi services patroni service\nLoaded: loaded (\/etc\/systemd\/system\/patroni.service; disabled; vendor preset: disabled)\nActive: inactive (dead)\nOct 24 15:29:08 hero3 patroni&#091;2014]: 2022-10-24 15:29:08,144 INFO: waiting for leader to bootstrap\nOct 24 15:29:18 hero3 patroni&#091;2014]: 2022-10-24 15:29:18,138 INFO: Lock owner: None; I am hero3\nOct 24 15:29:47 hero3 systemd&#091;1]: Stopping dbi services patroni service\u2026\nOct 24 15:29:47 hero3 systemd&#091;1]: patroni.service: Succeeded.\nOct 24 15:29:47 hero3 systemd&#091;1]: Stopped dbi services patroni service.<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-custom-bootstrap-method\">Custom Bootstrap Method<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">As a next step we need to create a custom bootstrap method to bootstrap from the latest pgBackRest Backup. According to the <a href=\"https:\/\/patroni.readthedocs.io\/en\/latest\/replica_bootstrap.html?highlight=custom%20bootstrap%20method\">Patroni documentation <\/a>this is quite easy.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">First of all let&#8217;s create a custom bootstrap file in the postgres user home called bootstrap_pgbackrest.sh. This file includes the restore command to restore from the pgBackRest backup.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>postgres@hero2:\/home\/postgres\/ &#091;PG1] cat bootstrap_pgbackrest.sh\n#!\/bin\/bash\npgbackrest --stanza=hero2hero --log-level-console=info restore\npostgres@hero2:\/home\/postgres\/ &#091;PG1] chmod +x bootstrap_pgbackrest.sh<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In the next step we need to adjust the patroni.yml on one host to use the new custom bootstrap method. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Add the following section in the bootstrap section that points to the custom bootstrap file we created.  <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>bootstrap:\n  # this section will be written into Etcd:\/\/\/config after initializing new cluster\n  # and all other cluster members will use it as a global configuration\n  method: pgbackrest\n  pgbackrest:\n    command: \/home\/postgres\/bootstrap_pgbackrest.sh\n    keep_existing_recovery_conf: False\n    no_paramas: False\n    recovery_conf:\n        recovery_target_action: promote\n        recovery_target_timeline: latest\n        restore_command: pgbackrest --stanza=hero2hero archive-get %f %p<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s try to start the patroni service again and see if it really bootstraps from the pgBackRest.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>postgres@hero3:\/u01\/app\/postgres\/local\/dmk\/etc\/ &#091;PG1] sudo systemctl status patroni\n\u25cf patroni.service - dbi services patroni service\n   Loaded: loaded (\/etc\/systemd\/system\/patroni.service; disabled; vendor preset: disabled)\n   Active: active (running) since Mon 2022-10-24 16:10:33 CEST; 1s ago\n  Process: 3020 ExecStartPre=\/usr\/bin\/sudo \/bin\/chown postgres \/dev\/watchdog (code=exited, status=0\/SUCCESS)\n  Process: 3017 ExecStartPre=\/usr\/bin\/sudo \/sbin\/modprobe softdog (code=exited, status=0\/SUCCESS)\n Main PID: 3024 (patroni)\n    Tasks: 5 (limit: 11364)\n   Memory: 19.8M\n   CGroup: \/system.slice\/patroni.service\n           \u2514\u25003024 \/usr\/bin\/python3.9 \/u01\/app\/postgres\/local\/dmk\/bin\/patroni \/u01\/app\/postgres\/local\/dmk\/etc\/patroni.yml\n\nOct 24 16:10:33 hero3 systemd&#091;1]: Starting dbi services patroni service...\nOct 24 16:10:33 hero3 sudo&#091;3017]: postgres : TTY=unknown ; PWD=\/ ; USER=root ; COMMAND=\/sbin\/modprobe softdog\nOct 24 16:10:33 hero3 sudo&#091;3020]: postgres : TTY=unknown ; PWD=\/ ; USER=root ; COMMAND=\/bin\/chown postgres \/dev\/watchdog\nOct 24 16:10:33 hero3 systemd&#091;1]: Started dbi services patroni service.\nOct 24 16:10:34 hero3 patroni&#091;3024]: 2022-10-24 16:10:34,395 INFO: Selected new etcd server http:\/\/192.168.22.251:2379\nOct 24 16:10:34 hero3 patroni&#091;3024]: 2022-10-24 16:10:34,404 INFO: No PostgreSQL configuration items changed, nothing to reload.\nOct 24 16:10:34 hero3 patroni&#091;3024]: 2022-10-24 16:10:34,433 INFO: Lock owner: None; I am hero3\nOct 24 16:10:34 hero3 patroni&#091;3024]: 2022-10-24 16:10:34,438 INFO: waiting for leader to bootstrap\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Hm&#8230;.that&#8217;s not what I expected. Unfortunately it is waiting for a primary. So seems like there is something missing \/ wrong. And the key to this is really simple. When we list the Patroni members we can see that all nodes are in &#8220;stopped&#8221; state. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> postgres@hero3:\/u01\/app\/postgres\/local\/dmk\/etc\/ &#091;PG1] patronictl list PG1\n+--------+----------------+---------+---------+----+-----------+\n| Member | Host           | Role    | State   | TL | Lag in MB |\n+ Cluster: PG1 (7157976722952275157) ---------+----+-----------+\n| hero1  | 192.168.22.251 | Replica | stopped |    |   unknown |\n| hero2  | 192.168.22.252 | Replica | stopped |    |   unknown |\n| hero3  | 192.168.22.253 | Replica | stopped |    |   unknown |\n+--------+----------------+---------+---------+----+-----------+<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Of course this is the missing step. Etcd is still aware that the cluster is already initialized. So we need to delete the old cluster before we can bootstrap a new one. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> postgres@hero3:\/u02\/pgdata\/etcd\/member\/ &#091;PG1] patronictl remove PG1\n+--------+----------------+---------+---------+----+-----------+\n| Member | Host           | Role    | State   | TL | Lag in MB |\n+ Cluster: PG1 (7157976722952275157) ---------+----+-----------+\n| hero1  | 192.168.22.251 | Replica | stopped |    |   unknown |\n| hero2  | 192.168.22.252 | Replica | stopped |    |   unknown |\n| hero3  | 192.168.22.253 | Replica | stopped |    |   unknown |\n+--------+----------------+---------+---------+----+-----------+\nPlease confirm the cluster name to remove: PG1\nYou are about to remove all information in DCS for PG1, please type: \"Yes I am aware\": Yes I am aware\n16:23:06 postgres@hero3:\/u02\/pgdata\/etcd\/member\/ &#091;PG1] patronictl list PG1\n+--------+------+------+-------+----+-----------+\n| Member | Host | Role | State | TL | Lag in MB |\n+ Cluster: PG1 (uninitialized) +----+-----------+\n+--------+------+------+-------+----+-----------+\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">We are gonna retry it once again to start the patroni service.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> postgres@hero2:\/u01\/app\/postgres\/local\/dmk\/etc\/ &#091;PG1] sudo systemctl start patroni\n15:39:06 postgres@hero2:\/u01\/app\/postgres\/local\/dmk\/etc\/ &#091;PG1] sudo systemctl status patroni\n\u25cf patroni.service - dbi services patroni service\n   Loaded: loaded (\/etc\/systemd\/system\/patroni.service; disabled; vendor preset: disabled)\n   Active: active (running) since Mon 2022-10-24 15:39:06 CEST; 4s ago\n  Process: 38620 ExecStartPre=\/usr\/bin\/sudo \/bin\/chown postgres \/dev\/watchdog (code=exited, status=0\/SUCCESS)\n  Process: 38616 ExecStartPre=\/usr\/bin\/sudo \/sbin\/modprobe softdog (code=exited, status=0\/SUCCESS)\n Main PID: 38626 (patroni)\n    Tasks: 10 (limit: 11364)\n   Memory: 136.6M\n   CGroup: \/system.slice\/patroni.service\n           \u251c\u250038626 \/usr\/bin\/python3.9 \/u01\/app\/postgres\/local\/dmk\/bin\/patroni \/u01\/app\/postgres\/local\/dmk\/etc\/patroni.yml\n           \u251c\u250038633 bin\/bash \/home\/postgres\/bootstrap_pgbackrest.sh --scope=PG1 --datadir=\/u02\/pgdata\/14\/PG1\/\n           \u251c\u250038634 pgbackrest --stanza=hero2hero --log-level-console=info --delta restore\n           \u251c\u250038639 pgbackrest --exec-id=38634-e965e985 --log-level-console=off --log-level-file=off --log-level-stderr=error --process=1 --remote-type=repo --stanza=hero2hero restore:local\n           \u2514\u250038640 ssh -o LogLevel=error -o Compression=no -o PasswordAuthentication=no postgres@192.168.22.250 pgbackrest --exec-id=38634-e965e985 --log-level-console=off --log-level-file=off --log-level-stderr=error --pg1-path=\/u02\/pgdata\/14\/PG1\/ --process=1 --remote-type=repo --repo=1 --repo1-path=&gt;\n\nOct 24 15:39:06 hero2 sudo&#091;38620]: postgres : TTY=unknown ; PWD=\/ ; USER=root ; COMMAND=\/bin\/chown postgres \/dev\/watchdog\nOct 24 15:39:06 hero2 systemd&#091;1]: Started dbi services patroni service.\nOct 24 15:39:06 hero2 patroni&#091;38626]: 2022-10-24 15:39:06,924 INFO: Selected new etcd server http:\/\/192.168.22.251:2379\nOct 24 15:39:06 hero2 patroni&#091;38626]: 2022-10-24 15:39:06,933 INFO: No PostgreSQL configuration items changed, nothing to reload.\nOct 24 15:39:06 hero2 patroni&#091;38626]: 2022-10-24 15:39:06,961 INFO: Lock owner: None; I am hero2\nOct 24 15:39:06 hero2 patroni&#091;38626]: 2022-10-24 15:39:06,971 INFO: trying to bootstrap a new cluster\nOct 24 15:39:06 hero2 patroni&#091;38626]: 2022-10-24 15:39:06,972 INFO: Running custom bootstrap script: \/home\/postgres\/bootstrap_pgbackrest.sh\nOct 24 15:39:06 hero2 patroni&#091;38634]: 2022-10-24 15:39:06.985 P00   INFO: restore command begin 2.41: --exec-id=38634-e965e985 --log-level-console=info --pg1-path=\/u02\/pgdata\/14\/PG1\/ --repo1-host=192.168.22.250 --repo1-host-user=postgres --repo1-path=\/u99\/backups --stanza=hero2hero\nOct 24 15:39:07 hero2 patroni&#091;38634]: 2022-10-24 15:39:07.568 P00   INFO: repo1: restore backup set 20221024-145020F, recovery will start at 2022-10-24 14:50:20\n\npostgres@hero2:\/u02\/pgdata\/14\/PG1\/ &#091;PG1] patronictl list\n+--------+----------------+--------+---------+----+-----------+\n| Member | Host           | Role   | State   | TL | Lag in MB |\n+ Cluster: PG1 (7157976722952275157) --------+----+-----------+\n| hero2  | 192.168.22.252 | Leader | running |  8 |           |\n+--------+----------------+--------+---------+----+-----------+\n\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">As you can see, it successfully boostraped using the custom bootstrap file. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-recreate-the-replicas\">Recreate the replicas<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">As the primary is finally back online we can add the replicas again.  <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This is pretty easy as we can bootstrap directly from the primary again.  Which works pretty well for both hosts.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>postgres@hero1:\/home\/postgres\/ &#091;PG1] sudo systemctl status patroni\n\u25cf patroni.service - dbi services patroni service\n   Loaded: loaded (\/etc\/systemd\/system\/patroni.service; enabled; vendor preset: disabled)\n   Active: active (running) since Mon 2022-10-24 18:25:33 CEST; 2s ago\n  Process: 8656 ExecReload=\/bin\/kill -s HUP $MAINPID (code=exited, status=0\/SUCCESS)\n  Process: 8708 ExecStartPre=\/usr\/bin\/sudo \/bin\/chown postgres \/dev\/watchdog (code=exited, status=0\/SUCCESS)\n  Process: 8705 ExecStartPre=\/usr\/bin\/sudo \/sbin\/modprobe softdog (code=exited, status=0\/SUCCESS)\n Main PID: 8713 (patroni)\n    Tasks: 9 (limit: 11364)\n   Memory: 128.9M\n   CGroup: \/system.slice\/patroni.service\n           \u251c\u25008713 \/usr\/bin\/python3.9 \/u01\/app\/postgres\/local\/dmk\/bin\/patroni \/u01\/app\/postgres\/local\/dmk\/etc\/patroni.yml\n           \u251c\u25008720 pgbackrest --stanza=hero2hero restore\n           \u251c\u25008725 pgbackrest --exec-id=8720-f8ab7b63 --log-level-console=off --log-level-file=off --log-level-stderr=error --process=1 --remote-type=repo --stanza=hero2hero restore:local\n           \u2514\u25008726 ssh -o LogLevel=error -o Compression=no -o PasswordAuthentication=no postgres@192.168.22.250 pgbackrest --exec-id=8720-f8ab7b63 --log-level-console=off --log-level-file=off --log-level-stderr=error --pg1-path=\/u02\/pgdata\/14\/PG1\/ --process=1 --remote-type=repo --repo=1 --repo1-path=\/u&gt;\n\nOct 24 18:25:33 hero1 systemd&#091;1]: Starting dbi services patroni service...\nOct 24 18:25:33 hero1 sudo&#091;8705]: postgres : TTY=unknown ; PWD=\/ ; USER=root ; COMMAND=\/sbin\/modprobe softdog\nOct 24 18:25:33 hero1 sudo&#091;8708]: postgres : TTY=unknown ; PWD=\/ ; USER=root ; COMMAND=\/bin\/chown postgres \/dev\/watchdog\nOct 24 18:25:33 hero1 systemd&#091;1]: Started dbi services patroni service.\nOct 24 18:25:33 hero1 patroni&#091;8713]: 2022-10-24 18:25:33,542 INFO: Selected new etcd server http:\/\/192.168.22.253:2379\nOct 24 18:25:33 hero1 patroni&#091;8713]: 2022-10-24 18:25:33,550 INFO: No PostgreSQL configuration items changed, nothing to reload.\nOct 24 18:25:33 hero1 patroni&#091;8713]: 2022-10-24 18:25:33,573 INFO: Lock owner: hero3; I am hero1\nOct 24 18:25:33 hero1 patroni&#091;8713]: 2022-10-24 18:25:33,577 INFO: trying to bootstrap from leader 'hero3'\n\n\npostgres@hero1:\/u02\/pgdata\/14\/PG1\/ &#091;PG1] patronictl list\n+--------+----------------+---------+---------+----+-----------+\n| Member | Host           | Role    | State   | TL | Lag in MB |\n+ Cluster: PG1 (7157976722952275157) ---------+----+-----------+\n| hero1  | 192.168.22.251 | Replica | running |  8 |         0 |\n| hero2  | 192.168.22.252 | Leader  | running |  8 |           |\n| hero3  | 192.168.22.253 | Replica | running |  8 |         0 |\n+--------+----------------+---------+---------+----+-----------+\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Always have a detailed look on your patroni.yml file. Small mistakes can really cost you a lot of time (especially blanks at the wrong place). In case of a mistake while restoring the primary from the backup, don&#8217;t forget to run &#8220;patronictl remove &lt;CLUSTERNAME&gt;&#8221; once again. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In case you want to recreate your Replicas from pgBackRest Backup again, just create a new Backup before you reinit the Replica.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>While preparing myself for the pgconf.eu in Berlin this week I made a lot of research regarding Patroni and pgBackRest. I was aware that it&#8217;s possible to recreate a replica from a pgBackRest backup. But I was also wondering, what happens if the complete Patroni Cluster is gone. I know this is not the most&hellip;&nbsp;<\/p>\n","protected":false},"author":28,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"","neve_meta_content_width":0,"neve_meta_title_alignment":"","neve_meta_author_avatar":"","neve_post_elements_order":"","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":"","neve_meta_reading_time":"","_themeisle_gutenberg_block_has_review":false,"footnotes":""},"categories":[4133],"tags":[1543,1293],"class_list":["post-20145","post","type-post","status-publish","format-standard","category-database","tag-patroni","tag-pgbackrest"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v28.9 (Yoast SEO v29.0) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Bootstrap Patroni Cluster from pgBackRest Backup - dbi services Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.dbi-services.com\/blog\/bootstrap-patroni-cluster-from-pgbackrest-backup\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Bootstrap Patroni Cluster from pgBackRest Backup\" \/>\n<meta property=\"og:description\" content=\"While preparing myself for the pgconf.eu in Berlin this week I made a lot of research regarding Patroni and pgBackRest. I was aware that it&#8217;s possible to recreate a replica from a pgBackRest backup. But I was also wondering, what happens if the complete Patroni Cluster is gone. I know this is not the most&hellip;&nbsp;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.dbi-services.com\/blog\/bootstrap-patroni-cluster-from-pgbackrest-backup\/\" \/>\n<meta property=\"og:site_name\" content=\"dbi services Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/dbiservices\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-10-27T16:30:00+00:00\" \/>\n<meta name=\"author\" content=\"Open source Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@dbiservices\" \/>\n<meta name=\"twitter:site\" content=\"@dbiservices\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Open source Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/bootstrap-patroni-cluster-from-pgbackrest-backup\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/bootstrap-patroni-cluster-from-pgbackrest-backup\\\/\"},\"author\":{\"name\":\"Open source Team\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/0b4548362cac3eeff8b3eaf329e3530a\"},\"headline\":\"Bootstrap Patroni Cluster from pgBackRest Backup\",\"datePublished\":\"2022-10-27T16:30:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/bootstrap-patroni-cluster-from-pgbackrest-backup\\\/\"},\"wordCount\":467,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/#organization\"},\"keywords\":[\"Patroni\",\"pgbackrest\"],\"articleSection\":[\"Database\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/bootstrap-patroni-cluster-from-pgbackrest-backup\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/bootstrap-patroni-cluster-from-pgbackrest-backup\\\/\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/bootstrap-patroni-cluster-from-pgbackrest-backup\\\/\",\"name\":\"Bootstrap Patroni Cluster from pgBackRest Backup - dbi services Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#website\"},\"datePublished\":\"2022-10-27T16:30:00+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/bootstrap-patroni-cluster-from-pgbackrest-backup\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/bootstrap-patroni-cluster-from-pgbackrest-backup\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/bootstrap-patroni-cluster-from-pgbackrest-backup\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Bootstrap Patroni Cluster from pgBackRest Backup\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/\",\"name\":\"dbi services Blog\",\"description\":\"#BeSharing\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/#organization\",\"name\":\"dbi services\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/dbi-services-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/dbi-services-logo.png\",\"width\":512,\"height\":512,\"caption\":\"dbi services\"},\"image\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/dbiservices\\\/\",\"https:\\\/\\\/x.com\\\/dbiservices\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/dbi-services\\\/\",\"https:\\\/\\\/www.youtube.com\\\/user\\\/dbiservices\"],\"description\":\"Swiss IT consulting and services company specialized in efficient data infrastructures and platforms: databases, application servers, cloud, DevOps, digitalization, analytics, data quality and monitoring. Headquartered in Del\u00e9mont with offices in Nyon, Basel, Bern and Zurich.\",\"email\":\"info@dbi-services.com\",\"telephone\":\"+41 32 422 96 00\",\"legalName\":\"dbi services SA\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/0b4548362cac3eeff8b3eaf329e3530a\",\"name\":\"Open source Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/05\\\/open-source-author.png\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/05\\\/open-source-author.png\",\"contentUrl\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/05\\\/open-source-author.png\",\"caption\":\"Open source Team\"},\"description\":\"Posts published under the Open source Team account are collective contributions by the dbi services open infrastructure consultants. The practice covers open-source databases and platforms, PostgreSQL first of all, along with MySQL, MariaDB, and Linux, from architecture, replication, and high availability to performance tuning and operations under service level agreements, and contributes actively to the PostgreSQL community.\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/author\\\/open-source-team\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Bootstrap Patroni Cluster from pgBackRest Backup - dbi services Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.dbi-services.com\/blog\/bootstrap-patroni-cluster-from-pgbackrest-backup\/","og_locale":"en_US","og_type":"article","og_title":"Bootstrap Patroni Cluster from pgBackRest Backup","og_description":"While preparing myself for the pgconf.eu in Berlin this week I made a lot of research regarding Patroni and pgBackRest. I was aware that it&#8217;s possible to recreate a replica from a pgBackRest backup. But I was also wondering, what happens if the complete Patroni Cluster is gone. I know this is not the most&hellip;&nbsp;","og_url":"https:\/\/www.dbi-services.com\/blog\/bootstrap-patroni-cluster-from-pgbackrest-backup\/","og_site_name":"dbi services Blog","article_publisher":"https:\/\/www.facebook.com\/dbiservices\/","article_published_time":"2022-10-27T16:30:00+00:00","author":"Open source Team","twitter_card":"summary_large_image","twitter_creator":"@dbiservices","twitter_site":"@dbiservices","twitter_misc":{"Written by":"Open source Team","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.dbi-services.com\/blog\/bootstrap-patroni-cluster-from-pgbackrest-backup\/#article","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/bootstrap-patroni-cluster-from-pgbackrest-backup\/"},"author":{"name":"Open source Team","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/0b4548362cac3eeff8b3eaf329e3530a"},"headline":"Bootstrap Patroni Cluster from pgBackRest Backup","datePublished":"2022-10-27T16:30:00+00:00","mainEntityOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/bootstrap-patroni-cluster-from-pgbackrest-backup\/"},"wordCount":467,"commentCount":2,"publisher":{"@id":"https:\/\/www.dbi-services.com\/#organization"},"keywords":["Patroni","pgbackrest"],"articleSection":["Database"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.dbi-services.com\/blog\/bootstrap-patroni-cluster-from-pgbackrest-backup\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.dbi-services.com\/blog\/bootstrap-patroni-cluster-from-pgbackrest-backup\/","url":"https:\/\/www.dbi-services.com\/blog\/bootstrap-patroni-cluster-from-pgbackrest-backup\/","name":"Bootstrap Patroni Cluster from pgBackRest Backup - dbi services Blog","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/#website"},"datePublished":"2022-10-27T16:30:00+00:00","breadcrumb":{"@id":"https:\/\/www.dbi-services.com\/blog\/bootstrap-patroni-cluster-from-pgbackrest-backup\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.dbi-services.com\/blog\/bootstrap-patroni-cluster-from-pgbackrest-backup\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.dbi-services.com\/blog\/bootstrap-patroni-cluster-from-pgbackrest-backup\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.dbi-services.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Bootstrap Patroni Cluster from pgBackRest Backup"}]},{"@type":"WebSite","@id":"https:\/\/www.dbi-services.com\/blog\/#website","url":"https:\/\/www.dbi-services.com\/blog\/","name":"dbi services Blog","description":"#BeSharing","publisher":{"@id":"https:\/\/www.dbi-services.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.dbi-services.com\/#organization","name":"dbi services","url":"https:\/\/www.dbi-services.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2026\/09\/dbi-services-logo.png","contentUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2026\/09\/dbi-services-logo.png","width":512,"height":512,"caption":"dbi services"},"image":{"@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/dbiservices\/","https:\/\/x.com\/dbiservices","https:\/\/www.linkedin.com\/company\/dbi-services\/","https:\/\/www.youtube.com\/user\/dbiservices"],"description":"Swiss IT consulting and services company specialized in efficient data infrastructures and platforms: databases, application servers, cloud, DevOps, digitalization, analytics, data quality and monitoring. Headquartered in Del\u00e9mont with offices in Nyon, Basel, Bern and Zurich.","email":"info@dbi-services.com","telephone":"+41 32 422 96 00","legalName":"dbi services SA"},{"@type":"Person","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/0b4548362cac3eeff8b3eaf329e3530a","name":"Open source Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/05\/open-source-author.png","url":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/05\/open-source-author.png","contentUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/05\/open-source-author.png","caption":"Open source Team"},"description":"Posts published under the Open source Team account are collective contributions by the dbi services open infrastructure consultants. The practice covers open-source databases and platforms, PostgreSQL first of all, along with MySQL, MariaDB, and Linux, from architecture, replication, and high availability to performance tuning and operations under service level agreements, and contributes actively to the PostgreSQL community.","url":"https:\/\/www.dbi-services.com\/blog\/author\/open-source-team\/"}]}},"_links":{"self":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/20145","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/users\/28"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/comments?post=20145"}],"version-history":[{"count":0,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/20145\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media?parent=20145"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/categories?post=20145"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/tags?post=20145"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}