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 1tpOmz-004hqG-BR for pgsql-general@arkaria.postgresql.org; Tue, 04 Mar 2025 09:42:13 +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 1tpOmy-00Ax8q-4b for pgsql-general@arkaria.postgresql.org; Tue, 04 Mar 2025 09:42:12 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tpOmx-00Ax8i-Or for pgsql-general@lists.postgresql.org; Tue, 04 Mar 2025 09:42:11 +0000 Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tpOmu-000sJc-1I for pgsql-general@lists.postgresql.org; Tue, 04 Mar 2025 09:42:11 +0000 Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-aaedd529ba1so629568766b.1 for ; Tue, 04 Mar 2025 01:42:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1741081328; x=1741686128; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=3Vq5/Ofbo+dfWn8t8pbrVt+daGZZzM5R/5mZZn/S1mE=; b=fHoHUFWYGeAqiMyA5v0mH0mcVeW7r71UvOxAI8+PE4inUapOqpNjc+da0icFnu86Yf dnk0Nc8hWTgD02fM4i3VBfeB4Prabt2GDj1JD0I83ho/DchysZj1rlBDNVLNac0698va JDIw6Gg+JdTIz+ijP23id5twkyTBiiiB3/QRPtvzu6PNA8rkmOIYoNYM7/SBWGHGPEmN 0h9Zx9jKGUnsD6m4Lgr2cTvCpfMrEi7vOlDkVMb4UomPzSCcw+7KiX0vEMLmPT9l0tt9 gei+tgcHDuztuEAn2KtGDQEh8UWHlpwsJpfIByJ2TWdjibkl8WQtmAkKRZT5EANYWIN/ ho8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741081328; x=1741686128; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=3Vq5/Ofbo+dfWn8t8pbrVt+daGZZzM5R/5mZZn/S1mE=; b=qYebep072JrJwzJlJs0O0yUMy1y0Yh/xEWgTNofTesmIHIYBFFVtkn6jyFmN5ikMIJ CoLc+WCZEizrBzjOpoASLuixBmtQ1N10oDdafEGEPRfbJqYXUqV8L4PGUdQX9/B1DUt0 TjiEMm0XcFYY9L4OpEUn9IWsLBc2RuSr2Bc5CQeNneEKD4V5ZFq4iG3I0ryRpYn2eAc/ eZDrpwAZ1Yf0MtdOkKLY4WyQw3dSMz/I4ic2wt3Xkm0y+xHcuVj2v+1ogYE6h6b1AeYy qtwKgjsBFFFsADKk7U0TxBtM9QNrYAxYbS3cW7MRjMcx12ng0pw06J9MmEI3gQyAfnmG aOHQ== X-Forwarded-Encrypted: i=1; AJvYcCUU64RdBTxHn0RdtYXeyLl2zgL0oTjBzvzQ8b+T3TnX5YGIWSmkkihCbROp0qE/r8kbTBovT4v3MunRRZer@lists.postgresql.org X-Gm-Message-State: AOJu0YyMtxA3XWsQmWXhR+nXAGv5zWGojBDe+d7qxhqAPQsnzlZ9AsbH dEaZ4qnCeMLVZugAMAAG1symghSDmW2thlnTSOLb1uEd9hpLkeTD72VSmD7Wd1k= X-Gm-Gg: ASbGnct5mn7otOuTBGgPX43st524NOYVle5dqwSJ/YU8HjPdoEt8MHP3nw3lvL8wAUs KuXke1AIz3RLDVuMTkM5k3OfZNkiLc09CxpSzQ0LcI3R3ID+PrQb3cH/r8TZsO2kA2pIUVg//4P 5gA6THX0BAWL+1ZemUhwEn4kHSHlrOUPICkZVikSUbjL2ro3AQjorI87UaMswor3uOC2qk9f/Ty g6FqsDBsCIZO9BakGrIsRMVcU19s5WvKEz/ltW8bZVcLEjPZgWfgzzLwzkCKHLpKsV90M7af+1H DLB8pEetf+oNBEO9sqBbIpJQktjnuzQYhQz7skcm64AQ2wkFqUNPMSLaQBDw6xgG X-Google-Smtp-Source: AGHT+IGf4E324kDdVXYlvx8Yg4NprJLoMGcb4O2gK97CNgjaZ1lCeBG7QzBrIbpeNCBrTZ69PsESQA== X-Received: by 2002:a05:6402:2790:b0:5df:6a:54ea with SMTP id 4fb4d7f45d1cf-5e4d6adc7a0mr41426121a12.11.1741081328259; Tue, 04 Mar 2025 01:42:08 -0800 (PST) Received: from localhost.localdomain ([2001:871:5e:8014:9266:f655:fe13:2518]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ac1e9c1c0efsm146878166b.52.2025.03.04.01.42.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Mar 2025 01:42:08 -0800 (PST) Message-ID: Subject: Re: Review my steps for rollback to restore point From: Laurenz Albe To: chandan Kumar , pgsql-general@lists.postgresql.org Date: Tue, 04 Mar 2025 10:42:06 +0100 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.54.3 (3.54.3-1.fc41) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, 2025-03-04 at 14:26 +0530, chandan Kumar wrote: > Hello, > =C2=A0I hope you are doing fine. I need your expertise on below=C2=A0case= 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-=C2=A0 Create a restore point using pg_create_restore_point() > 3-=C2=A0 executed some DDL statement (CREATE VIEW,ADD INDEX,DROP INDEX) > 4-=C2=A0 Perform=C2=A0rollback using restore point > =C2=A0To 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: > =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_command 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 system= ctl 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_r= ecovery(); > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 After verificatio= n, finalize recovery: > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 touch /var/lib/po= stgresql/data/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/lib/postg= resql/data/recovery.conf > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Then restart Postg= reSQL. > 6. Reestablish replication=C2=A0 >=20 > Could you please help if my steps are correct ? Can we achieve rollback f= rom any > other approach without restoring basebackup? You have to create /var/lib/postgresql/data/recovery.signal *before* you start the server. Forget about "recovery.conf", that was before v12. You can set "recovery_target_action =3D 'promote'". Yours, Laurenz Albe