Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tpO56-004VaG-0K for pgsql-general@arkaria.postgresql.org; Tue, 04 Mar 2025 08:56:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tpO54-009rON-KE for pgsql-general@arkaria.postgresql.org; Tue, 04 Mar 2025 08:56:50 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tpO54-009rNr-3a for pgsql-general@lists.postgresql.org; Tue, 04 Mar 2025 08:56:50 +0000 Received: from mail-yb1-xb2b.google.com ([2607:f8b0:4864:20::b2b]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tpO51-000sTg-2n for pgsql-general@lists.postgresql.org; Tue, 04 Mar 2025 08:56:49 +0000 Received: by mail-yb1-xb2b.google.com with SMTP id 3f1490d57ef6-e549b0f8d57so4582603276.3 for ; Tue, 04 Mar 2025 00:56:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741078607; x=1741683407; darn=lists.postgresql.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=WoN/nf1NOGLcbAZW9teEGM38XHujOsUI0eWaRjtGGv0=; b=AzGpxq2HbbICluZz3lCf6feSlCjjydBSxNzTPi0D4ArrZjiHhMvJgKSVcrKJNfJZ5t +2m6+XN0iM+Q7okmy9+xIFYSk1Xi+T/D+viN/ufY5IaCmviE/TtRzVNUPq4RD8OYRsbv 19oRiuD+WeQnl1zDvjXWQGJmQB4MHrY2HvxAORtsmY+WeJbQlwo6XIPmZqX9E7CP7D7I 2g/COyWvnzvnL7W0ixjzw0+tGHh3ifWE0nvOSHJLW4Gwg9ugmJ5NcC8YiSxUD2VhMqV3 nkH67z7Kk1Ll126uiL20um9BRPrpBMrbjw6Y4aT0ytw6m6SF35ZLvLouHPwFgAnQB4r0 9OVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741078607; x=1741683407; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=WoN/nf1NOGLcbAZW9teEGM38XHujOsUI0eWaRjtGGv0=; b=IQdIxdwn4Rzf7ClAoTvNajN/n0lkS1mbXb9ibxC8+O2FcXcbTAlqDOPt5YU4fjdk1+ lzLvih8vnZDfRlAq1V2ShI9vPQGbkD6JBv7TtROS3tOKznVS/P6i7jNUhcWidBvfbmpk V3cEtVCtuwxJ1W0HaiClcox5ByuWxdPyEzX8Rm9peIElWISkKhBq8FYFDnibLQOBhZlY FBM9hiYnP5I9ABtsfHOOqK8BgfivcM0gyFVODxkHgSneFaG4xdx4WE8aJerShdwoWfa4 x0Wxzqxx3n+7Hu887mKRuVyFm3OJjFXAgF1y8glVG5OzvMo23tZT3SOte6hN+ZsxOrsJ rxxA== X-Gm-Message-State: AOJu0Yztb+F+v/mDRixDkrx90D8gu0e7y8QXAVPLQpK1KdwHRwq6Gzkl XmvYXRHOuryO9VeM3qQcnU4G4gU1Cti3YHue3fB2SKvO+N6ZiD4COebtIPBht+CGSq+UIHh3hFM qSdKfM7yvwHWHTrDctqIYa86+81MsvAmP7UU= X-Gm-Gg: ASbGncvR6uIIz+Q6UyULQRwAEOqoKSUqh4F9/DmX8QwQhlFI+NVZeDOGuM2wXRLtA3z iLUAkfDxhRrKQcQshABK2kFXI2APvd2OHgNXFuLtFjX72c2l8+WpiW1MG/MLVmmzdf8gHNHArH0 f1h+ShzmMjCMSWCdeP0kluqv0G0jU= X-Google-Smtp-Source: AGHT+IF4ix1aL2bntwVDznBzd+hsR9WBoZ/LOPjriV8UfoDGqnK1wUFkLl3y0DS1mcP1eklkFdNO3emmgNSY4bsVOZs= X-Received: by 2002:a05:6902:2308:b0:e38:b34d:121f with SMTP id 3f1490d57ef6-e60b2ea043dmr18140749276.15.1741078606939; Tue, 04 Mar 2025 00:56:46 -0800 (PST) MIME-Version: 1.0 From: chandan Kumar Date: Tue, 4 Mar 2025 14:26:34 +0530 X-Gm-Features: AQ5f1Jo4_G77fY5UGBRkWOEuzxto_yGZiaGfZNhNP6Vi1E4m1UsXoWWGncsnMC4 Message-ID: Subject: Review my steps for rollback to restore point To: pgsql-general@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000e48d89062f807316" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000e48d89062f807316 Content-Type: text/plain; charset="UTF-8" Hello, I hope you are doing fine. I need your expertise on below case study. My current production environment is 2 node streaming replication hosted on Ubuntu VM 's on Azure. I have performed below steps on primary database. 1- Take Base backup 2- Create a restore point using pg_create_restore_point() 3- executed some DDL statement (CREATE VIEW,ADD INDEX,DROP INDEX) 4- Perform rollback using restore point To rollback, you must stop PostgreSQL, restore the last full backup, and apply WAL files until the restore point: 1. Stop PostgreSQL Service 2. Restore from Full Backup (Using pg_basebackup) 3. Modify recovery.conf (or postgresql.conf for newer versions) o Set recovery target name: recovery_target_name = 'before_ddl_changes' recovery_target_action = 'pause' o Set restore_command to replay WAL logs: restore_command = 'cp /path/to/wal_archive/%f %p' 4. Start PostgreSQL sudo systemctl start postgresql 5. Verify Recovery Status SELECT pg_is_in_recovery(); After verification, finalize recovery: touch /var/lib/postgresql/data/recovery.signal or rm /var/lib/postgresql/data/recovery.conf Then restart PostgreSQL. 6. Reestablish replication Could you please help if my steps are correct ? Can we achieve rollback from any other approach without restoring basebackup? -- *With warm regards* * Chandan* --000000000000e48d89062f807316 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello,
=C2=A0I hope you are doing fine. I n= eed your expertise on below=C2=A0case study.
My current productio= n environment is 2 node streaming replication hosted on Ubuntu VM 's on= Azure. I have performed below steps on primary database.
1- Take Base b= ackup
2-=C2=A0 Create a restore point using pg_create_restore_poi= nt()
3-=C2=A0 executed some DDL statement (CREATE VIEW,ADD INDEX,DROP IN= DEX)
4-=C2=A0 Perform=C2=A0rollback using restore point
=C2=A0= To rollback, you must stop PostgreSQL, restore the last full backup, and ap= ply WAL files until the restore point:
1. Stop PostgreSQL Service
2= . Restore from Full Backup (Using pg_basebackup)
3. Modify recovery.conf= (or postgresql.conf for newer versions)
o Set recovery target name:
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 recovery_target_name =3D 'before_ddl_changes'
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 recovery_target_action =3D 'pause'
o Set restore_comm= and to replay WAL logs:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0restore_command =3D 'cp /path/to/= wal_archive/%f %p'
4. Start PostgreSQL
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sudo systemctl start postgresql
5.= Verify Recovery Status
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 SELECT pg_is_in_recovery();
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 After verification, finalize recovery:
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 touch /var/lib/postgresql/dat= a/recovery.signal
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 or
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 rm /var/l= ib/postgresql/data/recovery.conf
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0Then restart PostgreSQL.
6. Reestablish replication=C2= =A0

Could you please help if my steps are correct ? = Can we achieve rollback from any other approach without restoring basebacku= p?

--
With warm regards
=C2=A0=C2=A0=C2=A0=C2=A0 Chandan
--000000000000e48d89062f807316--