Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V7nW0-0007Rz-Ee for pgsql-general@arkaria.postgresql.org; Fri, 09 Aug 2013 14:18:04 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1V7nVz-0001El-Le for pgsql-general@arkaria.postgresql.org; Fri, 09 Aug 2013 14:18:03 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V7nVy-0001EX-Jn for pgsql-general@postgresql.org; Fri, 09 Aug 2013 14:18:02 +0000 Received: from mail-pb0-x22f.google.com ([2607:f8b0:400e:c01::22f]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V7nVv-0003pa-21 for pgsql-general@postgresql.org; Fri, 09 Aug 2013 14:18:02 +0000 Received: by mail-pb0-f47.google.com with SMTP id rr4so3659817pbb.34 for ; Fri, 09 Aug 2013 07:17:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=rfgolHor9K8cHAJwnXyXtE5Re15ZeNDCQkrcZONvhvc=; b=m4D3ZXQb6Lsc2/hOiQZzBxsGv2O9B1McppdQWcw3HL1EY7tn9IadewJ301pcMZ05ea w5uG5vl8g0K82J1/L1kP5rEK18yzCVliomwo7lOeBCUAqwF/ni5CvCl3NLIcDX/CyfbN +ovADTGv5DTw5wE+l93nC78CPdWOyxHKTyKn8MOWV0S5Ond4p0MX5F44FxQVbfU667ct MPXi/dEeEPprug25F99l4FybNlbkT/DX/lwOttrPkoFNJtzTbjEGDi2CEtxgQ1ePPz5h JvdJ9g9bJyCVw7XGYZ/YQE0be6mi5SVXyOi7ziYdlL1Enh/UzZUAMZeKVpfqU+UpCVb6 5UGg== X-Received: by 10.68.178.133 with SMTP id cy5mr668499pbc.110.1376057876566; Fri, 09 Aug 2013 07:17:56 -0700 (PDT) Received: from [192.168.0.102] (014136185055.ctinets.com. [14.136.185.55]) by mx.google.com with ESMTPSA id eq5sm20404949pbc.15.2013.08.09.07.17.54 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 09 Aug 2013 07:17:56 -0700 (PDT) Subject: Re: Recovery.conf and PITR by recovery_target_time Mime-Version: 1.0 (Apple Message framework v1085) Content-Type: text/plain; charset=us-ascii From: "ascot.moss@gmail.com" In-Reply-To: Date: Fri, 9 Aug 2013 22:17:50 +0800 Cc: "ascot.moss@gmail.com" , PostgreSQL general Content-Transfer-Encoding: quoted-printable Message-Id: References: <1375985902.2599.YahooMailNeo@web162904.mail.bf1.yahoo.com> <22CFCCDF-F7A3-4F5C-A3B5-5BBE01708AB8@gmail.com> To: Albe Laurenz X-Mailer: Apple Mail (2.1085) X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-general Precedence: bulk Sender: pgsql-general-owner@postgresql.org hi >> 16:47:12 SELECT pg_start_backup('hot_backup'); "tar cfP" the PG "data" folder SELECT pg_stop_backup(); regards On 9 Aug 2013, at 9:55 PM, Albe Laurenz wrote: > ascot.moss@gmail.com wrote: >> I am trying another way to test PITR: by recovery_target_time. >>=20 >> The test machine has the same PG version 9.2.4 and same O/S Ubuntu 12.04= 64 bit. All archived WAL >> files are shipped and saved in /var/pgsql/data/archive, the latest time = stamp of them is "2013-08-09 >> 19:30:01", the full hot backup time is at '2013-08-09 16:47:12'. >>=20 >> Case 1) I want to recover PG to the state before 18:03:02 that there wer= e 6 tables deleted >> Case 2) Hope to recover PG to the point of time right before table TEST8= was created >>=20 >> Transactions in master: >> 16:45:01 (create 4 test tables : test1, test2, test3, test4) >> 16:47:12 (FULL HOT BACKUP) >> 17:50:22 postgres=3D# CREATE TABLE test5 (id INTEGER PRIMARY KEY); INS= ERT INTO test5 VALUES >> (generate_series(1,4000000)); EXPLAIN ANALYZE SELECT COUNT(*) FROM test= 5; >> 17:57:13 postgres=3D# CREATE TABLE test6 (id INTEGER PRIMARY KEY); INS= ERT INTO test6 VALUES >> (generate_series(1,1000000)); EXPLAIN ANALYZE SELECT COUNT(*) FROM test= 6; >> postgres=3D# \d >> List of relations >> Schema | Name | Type | Owner >> --------+-------+-------+---------- >> public | test1 | table | postgres (created before full hot backup) >> public | test2 | table | postgres (created before full hot backup) >> public | test3 | table | postgres (created before full hot backup) >> public | test4 | table | postgres (created before full hot backup) >> public | test5 | table | postgres >> public | test6 | table | postgres >> 18:03:02 postgres=3D# drop table test1; DROP TABLE >> postgres=3D# drop table test2; DROP TABLE >> postgres=3D# drop table test3; DROP TABLE >> postgres=3D# drop table test4; DROP TABLE >> postgres=3D# drop table test5; DROP TABLE >> postgres=3D# drop table test6; DROP TABLE >> postgres=3D# commit; WARNING: there is no transaction in progress COM= MIT >> 18:04:34 postgres=3D# CREATE TABLE test7 (id INTEGER PRIMARY KEY); INSE= RT INTO test7 VALUES >> (generate_series(1,1000000)); EXPLAIN ANALYZE SELECT COUNT(*) FROM test= 7; >> 18:11:31 postgres=3D# CREATE TABLE test8 (id INTEGER PRIMARY KEY); INSER= T INTO test8 VALUES >> (generate_series(1,1000000)); EXPLAIN ANALYZE SELECT COUNT(*) FROM test8; >> postgres=3D# CREATE TABLE test9 (id INTEGER PRIMARY KEY); INSERT INTO= test9 VALUES >> (generate_series(1,1000000)); EXPLAIN ANALYZE SELECT COUNT(*) FROM test9; >> postgres=3D# CREATE TABLE test10 (id INTEGER PRIMARY KEY); INSERT INT= O test10 VALUES >> (generate_series(1,1000000)); EXPLAIN ANALYZE SELECT COUNT(*) FROM test1= 0; >> 19:26:18 postgres=3D# vacuum; >> VACUUM >> postgres=3D# begin; INSERT INTO test10 VALUES >> (generate_series(2000002,3000002));commit; end; BEGIN INSERT 0 1000001 C= OMMIT WARNING: there is no >> transaction in progress COMMIT >> postgres=3D# CREATE TABLE test11 (id INTEGER PRIMARY KEY); INSERT INT= O test11 VALUES >> (generate_series(1,1000000)); EXPLAIN ANALYZE SELECT COUNT(*) FROM test1= 1; >> 19:30:01 (ship the WAL file to test machine) >>=20 >>=20 >>=20 >>=20 >> CASE-1: '2013-08-09 17:57:55' (only 3 lines in recovery.conf) >> restore_command =3D 'cp /var/pgsql/data/archive/%f %p' >> recovery_target_time =3D '2013-08-09 17:57:55' >> recovery_target_inclusive =3D false >> Result: >> LOG: starting point-in-time recovery to 2013-08-09 17:57:55 >> LOG: restored log file "000000010000006F00000066" from archive >> LOG: redo starts at 6F/66000020 >> LOG: recovery stopping before commit of transaction 75891, time 2013= -08-09 >> 18:07:09.547682+08 >> LOG: redo done at 6F/66003DF0 >> FATAL: requested recovery stop point is before consistent recovery p= oint >> LOG: startup process (PID 15729) exited with exit code 1 >> LOG: terminating any other active server processes >> [1]+ Exit 1 ... >>=20 >> CASE-2: '2013-08-09 18:06:01' (only 3 lines in recovery.conf) >> restore_command =3D 'cp /var/pgsql/data/archive/%f %p' >> recovery_target_time =3D '2013-08-09 18:06:01' >> recovery_target_inclusive =3D false >> Result: >> LOG: starting point-in-time recovery to 2013-08-09 18:06:01 >> LOG: restored log file "000000010000006F000000B0" from archive >> LOG: restored log file "000000010000006F0000009B" from archive >> LOG: redo starts at 6F/9B000020 >> LOG: recovery stopping before commit of transaction 75967, time 2013= -08-09 >> 19:30:10.217888+08 >> LOG: redo done at 6F/9B003500 >> FATAL: requested recovery stop point is before consistent recovery p= oint >> LOG: startup process (PID 19100) exited with exit code 1 >> LOG: terminating any other active server processes >> [1]+ Exit 1 ... >>=20 >>=20 >> So far I can only restore ALL (i.e. up to 19:30:01) but cannot recover P= G at certain Point-of-time. >=20 > The error message: > FATAL: requested recovery stop point is before consistent recovery point > suggests to me that the online backup had not ended at that time. >=20 > What exactly did you do at 16:47:12? > Did you call pg_stop_backup() after your backup? > Is there a file "backup_label" in your data directory? > You can only recover to a point in time *after* the time of backup comple= tion. >=20 > Another hint: specify the time zone for recovery_target_time, like > 2013-08-09 18:06:01 PST >=20 > Yours, > Laurenz Albe --=20 Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general