{"id":1975,"date":"2018-08-20T14:12:33","date_gmt":"2018-08-20T14:12:33","guid":{"rendered":"http:\/\/dbtut.com\/?p=1975"},"modified":"2018-11-11T20:51:56","modified_gmt":"2018-11-11T20:51:56","slug":"postgresql-pg_rewind","status":"publish","type":"post","link":"https:\/\/dbtut.com\/index.php\/2018\/08\/20\/postgresql-pg_rewind\/","title":{"rendered":"PostgreSQL pg_rewind"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p><span style=\"font-family: verdana, geneva, sans-serif; font-size: 10pt;\"><strong><u>Introduction : &#8211;\u00a0<\/u><\/strong><\/span><\/p>\n<p><span style=\"font-family: verdana, geneva, sans-serif; font-size: 10pt;\">pg_rewind\u00a0is a tool for synchronizing a PostgreSQL cluster with another copy of the same cluster, after the clusters&#8217; timelines have diverged. A typical scenario is to bring an old master server back online after failover as a standby that follows the new master.<\/span><\/p>\n<p><span style=\"font-family: verdana, geneva, sans-serif; font-size: 10pt;\">The result is equivalent to replacing the target data directory with the source one. Only changed blocks from relation files are copied; all other files are copied in full, including configuration files. The advantage of\u00a0pg_rewind\u00a0over taking a new base backup, or tools like\u00a0rsync, is that\u00a0pg_rewind\u00a0does not require reading through unchanged blocks in the cluster. This makes it a lot faster when the database is large and only a small fraction of blocks differ between the clusters.<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-family: verdana, geneva, sans-serif; font-size: 10pt;\"><strong><u>How it works :-\u00a0<\/u><\/strong><\/span><\/p>\n<p><span style=\"font-family: verdana, geneva, sans-serif; font-size: 10pt;\">The basic idea is to copy all file system-level changes from the source cluster to the target cluster<\/span><\/p>\n<ol>\n<li><span style=\"font-family: verdana, geneva, sans-serif; font-size: 10pt;\">Scan the WAL log of the target cluster, starting from the last checkpoint before the point where the source cluster&#8217;s timeline history forked off from the target cluster. For each WAL record, record each data block that was touched. This yields a list of all the data blocks that were changed in the target cluster, after the source cluster forked off.<\/span><\/li>\n<li><span style=\"font-family: verdana, geneva, sans-serif; font-size: 10pt;\">Copy all those changed blocks from the source cluster to the target cluster, either using direct file system access (&#8211;source-pgdata) or SQL (&#8211;source-server).<\/span><\/li>\n<li><span style=\"font-family: verdana, geneva, sans-serif; font-size: 10pt;\">Copy all other files such as pg_clog and configuration files from the source cluster to the target cluster (everything except the relation files).<\/span><\/li>\n<li><span style=\"font-family: verdana, geneva, sans-serif; font-size: 10pt;\">Apply the WAL from the source cluster, starting from the checkpoint created at failover. (Strictly speaking, pg_rewind doesn&#8217;t apply the WAL, it just creates a backup label file that makes PostgreSQL start by replaying all WAL from that checkpoint forward.)<\/span><\/li>\n<li style=\"list-style-type: none;\"><\/li>\n<\/ol>\n<p><span style=\"font-family: verdana, geneva, sans-serif; font-size: 10pt;\"><strong><u>Configure Replication : &#8211;\u00a0<\/u><\/strong><\/span><\/p>\n<p><span style=\"font-family: verdana, geneva, sans-serif; font-size: 10pt;\"><a href=\"http:\/\/3.bp.blogspot.com\/-BIL1o0OZk34\/WqdiCBQtx2I\/AAAAAAAAGWc\/1w6-qPFs3MMdKLwE5wZJXDl93gKNYfKuwCK4BGAYYCw\/s1600\/2.PNG\"><img decoding=\"async\" src=\"https:\/\/3.bp.blogspot.com\/-BIL1o0OZk34\/WqdiCBQtx2I\/AAAAAAAAGWc\/1w6-qPFs3MMdKLwE5wZJXDl93gKNYfKuwCK4BGAYYCw\/s1600\/2.PNG\" border=\"0\" \/><\/a><\/span><br \/>\n<span style=\"font-family: verdana, geneva, sans-serif; font-size: 10pt;\">I have already configured replication between two server [9.6 PostgreSQL community version] .<\/span><\/p>\n<p><span style=\"font-family: verdana, geneva, sans-serif; font-size: 10pt;\">Here i have my replication setup .<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-family: verdana, geneva, sans-serif; font-size: 10pt;\"><u><strong>Situation of fail-over\u00a0:-\u00a0<\/strong><\/u><\/span><\/p>\n<ul>\n<li><span style=\"font-family: verdana, geneva, sans-serif; font-size: 10pt;\">DBA error<\/span><\/li>\n<li><span style=\"font-family: verdana, geneva, sans-serif; font-size: 10pt;\">Fail-over management tool error<\/span><\/li>\n<li><span style=\"font-family: verdana, geneva, sans-serif; font-size: 10pt;\">Fail-over script get wrong input which cause standby promotion .<\/span><\/li>\n<li><span style=\"font-family: verdana, geneva, sans-serif; font-size: 10pt;\">While doing fail-over test .<\/span><\/li>\n<\/ul>\n<p><span style=\"font-family: verdana, geneva, sans-serif; font-size: 10pt;\">When this kind of situation occurs and we want to re-attach to connect old master as new slave in less time [Bypassing pg_basebackup\/rsync] ,pg_rewind is a good solution to build new standby which start following new master .<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-family: verdana, geneva, sans-serif; font-size: 10pt;\"><strong><u>Use case of pg_rewind :-\u00a0<\/u><\/strong><\/span><\/p>\n<ul>\n<li><span style=\"font-family: verdana, geneva, sans-serif; font-size: 10pt;\">Performe fail-over<\/span><\/li>\n<li><span style=\"font-family: verdana, geneva, sans-serif; font-size: 10pt;\">Lode some data on both server [insert some rows\/create any object]<\/span><\/li>\n<li><span style=\"font-family: verdana, geneva, sans-serif; font-size: 10pt;\">perform pg_rewind so that old master [New standby] start following new master [old replica] .<\/span><\/li>\n<li><span style=\"font-family: verdana, geneva, sans-serif; font-size: 10pt;\">Check that both server are in sync and checking which was made on old master after fail-over\u00a0this should get roll-backed\u00a0.<\/span><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><strong><span style=\"font-family: verdana, geneva, sans-serif; font-size: 10pt;\">Step 1 :- Promote standby\u00a0server<\/span><\/strong><\/p>\n<p><span style=\"font-family: verdana, geneva, sans-serif; font-size: 10pt;\"><a href=\"http:\/\/2.bp.blogspot.com\/-PhM7ZmmUxcs\/WqdjBENoHLI\/AAAAAAAAGWk\/75VL7RiEKKwTgTjVoy_j9RePYkobyJJSwCK4BGAYYCw\/s1600\/3.PNG\"><img decoding=\"async\" src=\"https:\/\/2.bp.blogspot.com\/-PhM7ZmmUxcs\/WqdjBENoHLI\/AAAAAAAAGWk\/75VL7RiEKKwTgTjVoy_j9RePYkobyJJSwCK4BGAYYCw\/s1600\/3.PNG\" border=\"0\" \/><\/a><\/span><\/p>\n<p>&nbsp;<\/p>\n<p><strong><span style=\"font-family: verdana, geneva, sans-serif; font-size: 10pt;\">Step 2 : &#8211;<\/span><span style=\"font-family: verdana, geneva, sans-serif; font-size: 10pt;\"><u>Lode some data in New Master\u00a0<\/u><\/span><\/strong><\/p>\n<p><span style=\"font-family: verdana, geneva, sans-serif; font-size: 10pt;\"><a href=\"http:\/\/2.bp.blogspot.com\/-WLd8gXdqfjo\/WqdkH56VcZI\/AAAAAAAAGW0\/ZDTNh_BSIYkNegDk9pBtK4u6ZON7SuZDwCK4BGAYYCw\/s1600\/5.PNG\"><img loading=\"lazy\" decoding=\"async\" class=\"\" src=\"https:\/\/2.bp.blogspot.com\/-WLd8gXdqfjo\/WqdkH56VcZI\/AAAAAAAAGW0\/ZDTNh_BSIYkNegDk9pBtK4u6ZON7SuZDwCK4BGAYYCw\/s1600\/5.PNG\" width=\"712\" height=\"363\" border=\"0\" \/><\/a><\/span><\/p>\n<p><span style=\"font-family: verdana, geneva, sans-serif; font-size: 10pt;\"><u>Lode some data in Old master\u00a0<\/u><\/span><\/p>\n<p><span style=\"font-family: verdana, geneva, sans-serif; font-size: 10pt;\"><a href=\"http:\/\/4.bp.blogspot.com\/--FGfm26io4E\/WqdjuaRFFMI\/AAAAAAAAGWs\/ZwJ5WI6alMYB9LFSNLE-7zcxWhEFCOzJQCK4BGAYYCw\/s1600\/4.PNG\"><img loading=\"lazy\" decoding=\"async\" class=\"\" src=\"https:\/\/4.bp.blogspot.com\/--FGfm26io4E\/WqdjuaRFFMI\/AAAAAAAAGWs\/ZwJ5WI6alMYB9LFSNLE-7zcxWhEFCOzJQCK4BGAYYCw\/s1600\/4.PNG\" width=\"712\" height=\"322\" border=\"0\" \/><\/a><\/span><\/p>\n<p><span style=\"font-family: verdana, geneva, sans-serif; font-size: 10pt;\"><u><em>Now both server are totally out of sync ,Try to bring them in sync and old master server will start following to new master as a standby .<\/em><\/u><\/span><\/p>\n<p>&nbsp;<\/p>\n<p><strong><span style=\"font-family: verdana, geneva, sans-serif; font-size: 10pt;\">Step 3 : &#8211;<\/span><span style=\"font-family: verdana, geneva, sans-serif; font-size: 10pt;\">Perform pg_rewind to start old master sync with new master .<\/span><\/strong><\/p>\n<p><span style=\"font-family: verdana, geneva, sans-serif; font-size: 10pt;\"><a href=\"http:\/\/1.bp.blogspot.com\/-mcXK_AJqfOY\/WqdnO-I0r1I\/AAAAAAAAGXE\/J7kRRwGprYA7cYHx98OQu95-vJHFPZgkQCK4BGAYYCw\/s1600\/6.PNG\"><img loading=\"lazy\" decoding=\"async\" class=\"\" src=\"https:\/\/1.bp.blogspot.com\/-mcXK_AJqfOY\/WqdnO-I0r1I\/AAAAAAAAGXE\/J7kRRwGprYA7cYHx98OQu95-vJHFPZgkQCK4BGAYYCw\/s1600\/6.PNG\" width=\"728\" height=\"185\" border=\"0\" \/><\/a><\/span><\/p>\n<pre class=\"lang:default decode:true \">pg_rewind\u00a0 --target-pgdata=\/usr\/local\/Postgresql9.6\/data_master\/ --source-server=\"port=5444 host=Replica_server_ip\"<\/pre>\n<p><span style=\"font-family: verdana, geneva, sans-serif; font-size: 10pt;\"><span style=\"font-size: 10pt;\"><br \/>\n<strong>Step 4: &#8211;<\/strong><\/span><\/span><\/p>\n<p><span style=\"font-family: verdana, geneva, sans-serif; font-size: 10pt;\"><u><em>Note : &#8211; Before starting new standby ,Make changes in recovery.conf to change IP address and create replication slot on master server .<\/em><\/u><\/span><\/p>\n<p><span style=\"font-family: verdana, geneva, sans-serif; font-size: 10pt;\">Changes get roll-backed from old master which is not required and blocks which are updated those get replayed on new slave<\/span><\/p>\n<p><span style=\"font-family: verdana, geneva, sans-serif; font-size: 10pt;\"><a href=\"http:\/\/3.bp.blogspot.com\/-gUKjkxiZwDY\/WqdphdV4nzI\/AAAAAAAAGXM\/bidwMdGE2pgFPQWM8LIEHrSZ2q3D6vaygCK4BGAYYCw\/s1600\/8.png\"><img loading=\"lazy\" decoding=\"async\" class=\"\" src=\"https:\/\/3.bp.blogspot.com\/-gUKjkxiZwDY\/WqdphdV4nzI\/AAAAAAAAGXM\/bidwMdGE2pgFPQWM8LIEHrSZ2q3D6vaygCK4BGAYYCw\/s1600\/8.png\" width=\"746\" height=\"569\" border=\"0\" \/><\/a><\/span><\/p>\n<p><span style=\"font-family: verdana, geneva, sans-serif; font-size: 10pt;\"><a href=\"http:\/\/1.bp.blogspot.com\/-TuhxTolSZSA\/WqdpziZVYSI\/AAAAAAAAGXU\/n0K0oLlz7Rs1useLIf9Xy93rCT85BA-SACK4BGAYYCw\/s1600\/9.png\"><img loading=\"lazy\" decoding=\"async\" class=\"\" src=\"https:\/\/1.bp.blogspot.com\/-TuhxTolSZSA\/WqdpziZVYSI\/AAAAAAAAGXU\/n0K0oLlz7Rs1useLIf9Xy93rCT85BA-SACK4BGAYYCw\/s1600\/9.png\" width=\"739\" height=\"362\" border=\"0\" \/><\/a><\/span><\/p>\n\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_1975\" class=\"pvc_stats all  \" data-element-id=\"1975\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/dbtut.com\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Introduction : &#8211;\u00a0 pg_rewind\u00a0is a tool for synchronizing a PostgreSQL cluster with another copy of the same cluster, after the clusters&#8217; timelines have diverged. A typical scenario is to bring an old master server back online after failover as a standby that follows the new master. The result is equivalent to replacing the target &hellip;<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_1975\" class=\"pvc_stats all  \" data-element-id=\"1975\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/dbtut.com\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"author":91,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[5],"tags":[],"class_list":["post-1975","post","type-post","status-publish","format-standard","","category-postgres"],"aioseo_notices":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>PostgreSQL pg_rewind - Database Tutorials<\/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:\/\/dbtut.com\/index.php\/2018\/08\/20\/postgresql-pg_rewind\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PostgreSQL pg_rewind - Database Tutorials\" \/>\n<meta property=\"og:description\" content=\"&nbsp; Introduction : &#8211;\u00a0 pg_rewind\u00a0is a tool for synchronizing a PostgreSQL cluster with another copy of the same cluster, after the clusters&#8217; timelines have diverged. A typical scenario is to bring an old master server back online after failover as a standby that follows the new master. The result is equivalent to replacing the target &hellip;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/dbtut.com\/index.php\/2018\/08\/20\/postgresql-pg_rewind\/\" \/>\n<meta property=\"og:site_name\" content=\"Database Tutorials\" \/>\n<meta property=\"article:published_time\" content=\"2018-08-20T14:12:33+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-11-11T20:51:56+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/3.bp.blogspot.com\/-BIL1o0OZk34\/WqdiCBQtx2I\/AAAAAAAAGWc\/1w6-qPFs3MMdKLwE5wZJXDl93gKNYfKuwCK4BGAYYCw\/s1600\/2.PNG\" \/>\n<meta name=\"author\" content=\"Tushar Takate\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Tushar Takate\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/08\/20\/postgresql-pg_rewind\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/08\/20\/postgresql-pg_rewind\/\"},\"author\":{\"name\":\"Tushar Takate\",\"@id\":\"https:\/\/dbtut.com\/#\/schema\/person\/50e5a1f5f7875cce84765cd487986a7b\"},\"headline\":\"PostgreSQL pg_rewind\",\"datePublished\":\"2018-08-20T14:12:33+00:00\",\"dateModified\":\"2018-11-11T20:51:56+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/08\/20\/postgresql-pg_rewind\/\"},\"wordCount\":557,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/dbtut.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/08\/20\/postgresql-pg_rewind\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/3.bp.blogspot.com\/-BIL1o0OZk34\/WqdiCBQtx2I\/AAAAAAAAGWc\/1w6-qPFs3MMdKLwE5wZJXDl93gKNYfKuwCK4BGAYYCw\/s1600\/2.PNG\",\"articleSection\":[\"PostgreSQL\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/dbtut.com\/index.php\/2018\/08\/20\/postgresql-pg_rewind\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/08\/20\/postgresql-pg_rewind\/\",\"url\":\"https:\/\/dbtut.com\/index.php\/2018\/08\/20\/postgresql-pg_rewind\/\",\"name\":\"PostgreSQL pg_rewind - Database Tutorials\",\"isPartOf\":{\"@id\":\"https:\/\/dbtut.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/08\/20\/postgresql-pg_rewind\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/08\/20\/postgresql-pg_rewind\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/3.bp.blogspot.com\/-BIL1o0OZk34\/WqdiCBQtx2I\/AAAAAAAAGWc\/1w6-qPFs3MMdKLwE5wZJXDl93gKNYfKuwCK4BGAYYCw\/s1600\/2.PNG\",\"datePublished\":\"2018-08-20T14:12:33+00:00\",\"dateModified\":\"2018-11-11T20:51:56+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/08\/20\/postgresql-pg_rewind\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/dbtut.com\/index.php\/2018\/08\/20\/postgresql-pg_rewind\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/08\/20\/postgresql-pg_rewind\/#primaryimage\",\"url\":\"https:\/\/3.bp.blogspot.com\/-BIL1o0OZk34\/WqdiCBQtx2I\/AAAAAAAAGWc\/1w6-qPFs3MMdKLwE5wZJXDl93gKNYfKuwCK4BGAYYCw\/s1600\/2.PNG\",\"contentUrl\":\"https:\/\/3.bp.blogspot.com\/-BIL1o0OZk34\/WqdiCBQtx2I\/AAAAAAAAGWc\/1w6-qPFs3MMdKLwE5wZJXDl93gKNYfKuwCK4BGAYYCw\/s1600\/2.PNG\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/dbtut.com\/index.php\/2018\/08\/20\/postgresql-pg_rewind\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/dbtut.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PostgreSQL pg_rewind\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/dbtut.com\/#website\",\"url\":\"https:\/\/dbtut.com\/\",\"name\":\"Database Tutorials\",\"description\":\"MSSQL, Oracle, PostgreSQL, MySQL, MariaDB, DB2, Sybase, Teradata, Big Data, NOSQL, MongoDB, Couchbase, Cassandra, Windows, Linux\",\"publisher\":{\"@id\":\"https:\/\/dbtut.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/dbtut.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/dbtut.com\/#organization\",\"name\":\"dbtut\",\"url\":\"https:\/\/dbtut.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/dbtut.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2021\/02\/dbtutlogo.jpg\",\"contentUrl\":\"https:\/\/dbtut.com\/wp-content\/uploads\/2021\/02\/dbtutlogo.jpg\",\"width\":223,\"height\":36,\"caption\":\"dbtut\"},\"image\":{\"@id\":\"https:\/\/dbtut.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/dbtut.com\/#\/schema\/person\/50e5a1f5f7875cce84765cd487986a7b\",\"name\":\"Tushar Takate\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/dbtut.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/25f445c5bc4c3756385d6e17c96f7b550740e480b78a3cadd7411d019f2d1459?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/25f445c5bc4c3756385d6e17c96f7b550740e480b78a3cadd7411d019f2d1459?s=96&d=mm&r=g\",\"caption\":\"Tushar Takate\"},\"url\":\"https:\/\/dbtut.com\/index.php\/author\/tushartakate\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PostgreSQL pg_rewind - Database Tutorials","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:\/\/dbtut.com\/index.php\/2018\/08\/20\/postgresql-pg_rewind\/","og_locale":"en_US","og_type":"article","og_title":"PostgreSQL pg_rewind - Database Tutorials","og_description":"&nbsp; Introduction : &#8211;\u00a0 pg_rewind\u00a0is a tool for synchronizing a PostgreSQL cluster with another copy of the same cluster, after the clusters&#8217; timelines have diverged. A typical scenario is to bring an old master server back online after failover as a standby that follows the new master. The result is equivalent to replacing the target &hellip;","og_url":"https:\/\/dbtut.com\/index.php\/2018\/08\/20\/postgresql-pg_rewind\/","og_site_name":"Database Tutorials","article_published_time":"2018-08-20T14:12:33+00:00","article_modified_time":"2018-11-11T20:51:56+00:00","og_image":[{"url":"https:\/\/3.bp.blogspot.com\/-BIL1o0OZk34\/WqdiCBQtx2I\/AAAAAAAAGWc\/1w6-qPFs3MMdKLwE5wZJXDl93gKNYfKuwCK4BGAYYCw\/s1600\/2.PNG","type":"","width":"","height":""}],"author":"Tushar Takate","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Tushar Takate","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/dbtut.com\/index.php\/2018\/08\/20\/postgresql-pg_rewind\/#article","isPartOf":{"@id":"https:\/\/dbtut.com\/index.php\/2018\/08\/20\/postgresql-pg_rewind\/"},"author":{"name":"Tushar Takate","@id":"https:\/\/dbtut.com\/#\/schema\/person\/50e5a1f5f7875cce84765cd487986a7b"},"headline":"PostgreSQL pg_rewind","datePublished":"2018-08-20T14:12:33+00:00","dateModified":"2018-11-11T20:51:56+00:00","mainEntityOfPage":{"@id":"https:\/\/dbtut.com\/index.php\/2018\/08\/20\/postgresql-pg_rewind\/"},"wordCount":557,"commentCount":0,"publisher":{"@id":"https:\/\/dbtut.com\/#organization"},"image":{"@id":"https:\/\/dbtut.com\/index.php\/2018\/08\/20\/postgresql-pg_rewind\/#primaryimage"},"thumbnailUrl":"https:\/\/3.bp.blogspot.com\/-BIL1o0OZk34\/WqdiCBQtx2I\/AAAAAAAAGWc\/1w6-qPFs3MMdKLwE5wZJXDl93gKNYfKuwCK4BGAYYCw\/s1600\/2.PNG","articleSection":["PostgreSQL"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/dbtut.com\/index.php\/2018\/08\/20\/postgresql-pg_rewind\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/dbtut.com\/index.php\/2018\/08\/20\/postgresql-pg_rewind\/","url":"https:\/\/dbtut.com\/index.php\/2018\/08\/20\/postgresql-pg_rewind\/","name":"PostgreSQL pg_rewind - Database Tutorials","isPartOf":{"@id":"https:\/\/dbtut.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/dbtut.com\/index.php\/2018\/08\/20\/postgresql-pg_rewind\/#primaryimage"},"image":{"@id":"https:\/\/dbtut.com\/index.php\/2018\/08\/20\/postgresql-pg_rewind\/#primaryimage"},"thumbnailUrl":"https:\/\/3.bp.blogspot.com\/-BIL1o0OZk34\/WqdiCBQtx2I\/AAAAAAAAGWc\/1w6-qPFs3MMdKLwE5wZJXDl93gKNYfKuwCK4BGAYYCw\/s1600\/2.PNG","datePublished":"2018-08-20T14:12:33+00:00","dateModified":"2018-11-11T20:51:56+00:00","breadcrumb":{"@id":"https:\/\/dbtut.com\/index.php\/2018\/08\/20\/postgresql-pg_rewind\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/dbtut.com\/index.php\/2018\/08\/20\/postgresql-pg_rewind\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/dbtut.com\/index.php\/2018\/08\/20\/postgresql-pg_rewind\/#primaryimage","url":"https:\/\/3.bp.blogspot.com\/-BIL1o0OZk34\/WqdiCBQtx2I\/AAAAAAAAGWc\/1w6-qPFs3MMdKLwE5wZJXDl93gKNYfKuwCK4BGAYYCw\/s1600\/2.PNG","contentUrl":"https:\/\/3.bp.blogspot.com\/-BIL1o0OZk34\/WqdiCBQtx2I\/AAAAAAAAGWc\/1w6-qPFs3MMdKLwE5wZJXDl93gKNYfKuwCK4BGAYYCw\/s1600\/2.PNG"},{"@type":"BreadcrumbList","@id":"https:\/\/dbtut.com\/index.php\/2018\/08\/20\/postgresql-pg_rewind\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/dbtut.com\/"},{"@type":"ListItem","position":2,"name":"PostgreSQL pg_rewind"}]},{"@type":"WebSite","@id":"https:\/\/dbtut.com\/#website","url":"https:\/\/dbtut.com\/","name":"Database Tutorials","description":"MSSQL, Oracle, PostgreSQL, MySQL, MariaDB, DB2, Sybase, Teradata, Big Data, NOSQL, MongoDB, Couchbase, Cassandra, Windows, Linux","publisher":{"@id":"https:\/\/dbtut.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/dbtut.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/dbtut.com\/#organization","name":"dbtut","url":"https:\/\/dbtut.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/dbtut.com\/#\/schema\/logo\/image\/","url":"https:\/\/dbtut.com\/wp-content\/uploads\/2021\/02\/dbtutlogo.jpg","contentUrl":"https:\/\/dbtut.com\/wp-content\/uploads\/2021\/02\/dbtutlogo.jpg","width":223,"height":36,"caption":"dbtut"},"image":{"@id":"https:\/\/dbtut.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/dbtut.com\/#\/schema\/person\/50e5a1f5f7875cce84765cd487986a7b","name":"Tushar Takate","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/dbtut.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/25f445c5bc4c3756385d6e17c96f7b550740e480b78a3cadd7411d019f2d1459?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/25f445c5bc4c3756385d6e17c96f7b550740e480b78a3cadd7411d019f2d1459?s=96&d=mm&r=g","caption":"Tushar Takate"},"url":"https:\/\/dbtut.com\/index.php\/author\/tushartakate\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/posts\/1975","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/users\/91"}],"replies":[{"embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/comments?post=1975"}],"version-history":[{"count":0,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/posts\/1975\/revisions"}],"wp:attachment":[{"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/media?parent=1975"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/categories?post=1975"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dbtut.com\/index.php\/wp-json\/wp\/v2\/tags?post=1975"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}