PostgreSQL物理备份恢复之 pg_rman的用法说明

时间:2022-03-03 22:39:31

简介

类似oracle 的 rman, 用于 postgres的备份与恢复

下载

https://github.com/ossc-db/pg_rman/tree/V1.3.9

安装

?
1
2
3
4
5
tar zxvf pg_rman*.tar.gz
chown postgres.postgres -R pg_rman*
su - postgres
cd xxx/pg_rman*
make && make install

使用

开启归档

?
1
2
3
4
[postgres@node_206 /postgresql/pgsql/archive_log]$tail -3 /postgresql/pgsql/data/postgresql.conf
#for pg_Rman
archive_mode = on # enables archiving; off, on, or always
archive_command = 'test ! -f /postgresql/pgsql/archive_log/%f && cp %p /postgresql/pgsql/archive_log/%f'

重启 PG

?
1
pg_ctl restart -m fast

初始化

?
1
pg_rman init -B /postgresql/pgsql/pg_rman_backups

全量备份

?
1
pg_rman backup --backup-mode=full -B /postgresql/pgsql/pg_rman_backups

实例

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
[postgres@node_206 /postgresql/pgsql]$pg_rman init -B /postgresql/pgsql/pg_rman_backups/
INFO: ARCLOG_PATH is set to '/postgresql/pgsql/archive_log'
INFO: SRVLOG_PATH is set to '/postgresql/pgsql/pg_log'
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$vim ~/.bash_profile
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$source !$
source ~/.bash_profile
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$psql
psql (12.3)
Type "help" for help.
postgres=# \l
                 List of databases
  Name  | Owner  | Encoding |  Collate  |  Ctype  |  Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
 postgres | postgres | UTF8   | en_US.UTF-8 | en_US.UTF-8 |
 repmgr  | repmgr  | UTF8   | en_US.UTF-8 | en_US.UTF-8 |
 template0 | postgres | UTF8   | en_US.UTF-8 | en_US.UTF-8 | =c/postgres     +
      |     |     |       |       | postgres=CTc/postgres
 template1 | postgres | UTF8   | en_US.UTF-8 | en_US.UTF-8 | =c/postgres     +
      |     |     |       |       | postgres=CTc/postgres
 test   | postgres | UTF8   | en_US.UTF-8 | en_US.UTF-8 |
(5 rows)
postgres=# \c test
You are now connected to database "test" as user "postgres".
test=# select * from test;
 id |     crt_time    
----+----------------------------
 1 | 2020-11-17 23:23:31.407616
 2 | 2020-11-17 23:23:31.407728
 3 | 2020-11-17 23:23:31.407731
 4 | 2020-11-17 23:23:31.407732
 5 | 2020-11-17 23:23:31.407732
 6 | 2020-11-17 23:23:31.407733
 7 | 2020-11-17 23:23:31.407733
 8 | 2020-11-17 23:23:31.407734
 9 | 2020-11-17 23:23:31.407734
 10 | 2020-11-17 23:23:31.407735
(10 rows)
test=# insert into test (id) select n from generate_series(11,20) n;
INSERT 0 10
test=# \q
[postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -B /postgresql/pgsql/pg_rman_backups
INFO: copying database files
INFO: copying archived WAL files
INFO: backup complete
INFO: Please execute 'pg_rman validate' to verify the files are correctly copied.
[postgres@node_206 /postgresql/pgsql]$pg_rman validate -B /postgresql/pgsql/pg_rman_backups
INFO: validate: "2020-11-17 23:30:25" backup and archive log files by CRC
INFO: backup "2020-11-17 23:30:25" is valid
[postgres@node_206 /postgresql/pgsql]$pg_rman show
ERROR: required parameter not specified: BACKUP_PATH (-B, --backup-path)
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/
=====================================================================
 StartTime      EndTime       Mode  Size  TLI Status
=====================================================================
2020-11-17 23:30:25 2020-11-17 23:30:27 FULL  64MB   6 OK
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$psql
psql (12.3)
Type "help" for help.
postgres=# \c test
You are now connected to database "test" as user "postgres".
test=# insert into test (id) select n from generate_series(21,30) n;
INSERT 0 10
test=# \q
[postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=incremental -B /postgresql/pgsql/pg_rman_backups
INFO: copying database files
INFO: copying archived WAL files
INFO: backup complete
INFO: Please execute 'pg_rman validate' to verify the files are correctly copied.
[postgres@node_206 /postgresql/pgsql]$pg_rman validate -B /postgresql/pgsql/pg_rman_backups
INFO: validate: "2020-11-17 23:31:08" backup and archive log files by CRC
INFO: backup "2020-11-17 23:31:08" is valid
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/
=====================================================================
 StartTime      EndTime       Mode  Size  TLI Status
=====================================================================
2020-11-17 23:31:08 2020-11-17 23:31:10 INCR  33MB   6 OK
2020-11-17 23:30:25 2020-11-17 23:30:27 FULL  64MB   6 OK
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$psql
psql (12.3)
Type "help" for help.
postgres=# \c test
You are now connected to database "test" as user "postgres".
test=# drop table test;
DROP TABLE
test=# \q
[postgres@node_206 /postgresql/pgsql]$pg_ctl stop -m fast
waiting for server to shut down.... done
server stopped
[postgres@node_206 /postgresql/pgsql]$pg_ctl start
waiting for server to start....2020-11-17 10:32:09.637 EST [58824] LOG: 00000: starting PostgreSQL 12.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
2020-11-17 10:32:09.637 EST [58824] LOCATION: PostmasterMain, postmaster.c:998
2020-11-17 10:32:09.637 EST [58824] LOG: 00000: listening on IPv4 address "0.0.0.0", port 5432
2020-11-17 10:32:09.637 EST [58824] LOCATION: StreamServerPort, pqcomm.c:593
2020-11-17 10:32:09.637 EST [58824] LOG: 00000: listening on IPv6 address "::", port 5432
2020-11-17 10:32:09.637 EST [58824] LOCATION: StreamServerPort, pqcomm.c:593
2020-11-17 10:32:09.643 EST [58824] LOG: 00000: listening on Unix socket "/tmp/.s.PGSQL.5432"
2020-11-17 10:32:09.643 EST [58824] LOCATION: StreamServerPort, pqcomm.c:587
2020-11-17 10:32:09.688 EST [58824] LOG: 00000: redirecting log output to logging collector process
2020-11-17 10:32:09.688 EST [58824] HINT: Future log output will appear in directory "/postgresql/pgsql/pg_log".
2020-11-17 10:32:09.688 EST [58824] LOCATION: SysLogger_Start, syslogger.c:675
 done
server started
[postgres@node_206 /postgresql/pgsql]$psql -d test
psql (12.3)
Type "help" for help.
test=# insert into test (id ) select n from generate_series(21,30) n;
ERROR: relation "test" does not exist
LINE 1: insert into test (id ) select n from generate_series(21,30) ...
          ^
test=# insert into test (id ) select n from generate_series(21,30) n;
ERROR: relation "test" does not exist
LINE 1: insert into test (id ) select n from generate_series(21,30) ...
          ^
test=# \d test
Did not find any relation named "test".
test=# \q
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$repmgr cluster show
 ID | Name   | Role  | Status    | Upstream  | Location | Priority | Timeline | Connection string                    
----+----------+---------+---------------+------------+----------+----------+----------+-------------------------------------------------------------
 1 | node_206 | primary | * running   |      | default | 100   | 6    | host=node_206 user=repmgr dbname=repmgr connect_timeout=2
 2 | node_205 | standby | ? unreachable | ? node_206 | default | 100   |     | host=node_205 user=repmgr dbname=repmgr connect_timeout=2
WARNING: following issues were detected
 - unable to connect to node "node_205" (ID: 2)
 - node "node_205" (ID: 2) is registered as an active standby but is unreachable
HINT: execute with --verbose option to see connection error messages
[postgres@node_206 /postgresql/pgsql]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/
=====================================================================
 StartTime      EndTime       Mode  Size  TLI Status
=====================================================================
2020-11-17 23:31:08 2020-11-17 23:31:10 INCR  33MB   6 OK
2020-11-17 23:30:25 2020-11-17 23:30:27 FULL  64MB   6 OK
[postgres@node_206 /postgresql/pgsql]$pg_rman restore -B /postgresql/pgsql/pg_rman_backups/ --restore-target-time='2020-11-17 23:30:25'
pg_rman: unrecognized option '--restore-target-time=2020-11-17 23:30:25'
ERROR: option is not specified
HINT: Try "pg_rman --help" for more information.
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_rman restore -B /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-11-17 23:30:25'
ERROR: PostgreSQL server is running
HINT: Please stop PostgreSQL server before executing restore.
[postgres@node_206 /postgresql/pgsql]$pg_ctl stop -m fast
waiting for server to shut down.... done
server stopped
[postgres@node_206 /postgresql/pgsql]$pg_rman restore -B /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-11-17 23:30:25'
ERROR: cannot do restore
DETAIL: There is no valid full backup which can be used for given recovery condition.
[postgres@node_206 /postgresql/pgsql]$pg_rman validate -B /postgresql/pgsql/pg_rman_backups
[postgres@node_206 /postgresql/pgsql]$pg_rman restore -B /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-11-17 23:30:25'
ERROR: cannot do restore
DETAIL: There is no valid full backup which can be used for given recovery condition.
[postgres@node_206 /postgresql/pgsql]$pg_ctl start
waiting for server to start....2020-11-17 10:34:02.558 EST [58862] LOG: 00000: starting PostgreSQL 12.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
2020-11-17 10:34:02.558 EST [58862] LOCATION: PostmasterMain, postmaster.c:998
2020-11-17 10:34:02.559 EST [58862] LOG: 00000: listening on IPv4 address "0.0.0.0", port 5432
2020-11-17 10:34:02.559 EST [58862] LOCATION: StreamServerPort, pqcomm.c:593
2020-11-17 10:34:02.559 EST [58862] LOG: 00000: listening on IPv6 address "::", port 5432
2020-11-17 10:34:02.559 EST [58862] LOCATION: StreamServerPort, pqcomm.c:593
2020-11-17 10:34:02.565 EST [58862] LOG: 00000: listening on Unix socket "/tmp/.s.PGSQL.5432"
2020-11-17 10:34:02.565 EST [58862] LOCATION: StreamServerPort, pqcomm.c:587
2020-11-17 10:34:02.608 EST [58862] LOG: 00000: redirecting log output to logging collector process
2020-11-17 10:34:02.608 EST [58862] HINT: Future log output will appear in directory "/postgresql/pgsql/pg_log".
2020-11-17 10:34:02.608 EST [58862] LOCATION: SysLogger_Start, syslogger.c:675
 done
server started
[postgres@node_206 /postgresql/pgsql]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/
=====================================================================
 StartTime      EndTime       Mode  Size  TLI Status
=====================================================================
2020-11-17 23:31:08 2020-11-17 23:31:10 INCR  33MB   6 OK
2020-11-17 23:30:25 2020-11-17 23:30:27 FULL  64MB   6 OK
[postgres@node_206 /postgresql/pgsql]$pg_rman validate -B /postgresql/pgsql/pg_rman_backups
[postgres@node_206 /postgresql/pgsql]$pg_ctl stop
waiting for server to shut down.... done
server stopped
[postgres@node_206 /postgresql/pgsql]$pg_rman restore -B /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-11-17 23:30:25'
ERROR: cannot do restore
DETAIL: There is no valid full backup which can be used for given recovery condition.
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_ctl start
waiting for server to start....2020-11-17 10:34:22.842 EST [58881] LOG: 00000: starting PostgreSQL 12.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
2020-11-17 10:34:22.842 EST [58881] LOCATION: PostmasterMain, postmaster.c:998
2020-11-17 10:34:22.842 EST [58881] LOG: 00000: listening on IPv4 address "0.0.0.0", port 5432
2020-11-17 10:34:22.842 EST [58881] LOCATION: StreamServerPort, pqcomm.c:593
2020-11-17 10:34:22.842 EST [58881] LOG: 00000: listening on IPv6 address "::", port 5432
2020-11-17 10:34:22.842 EST [58881] LOCATION: StreamServerPort, pqcomm.c:593
2020-11-17 10:34:22.846 EST [58881] LOG: 00000: listening on Unix socket "/tmp/.s.PGSQL.5432"
2020-11-17 10:34:22.846 EST [58881] LOCATION: StreamServerPort, pqcomm.c:587
2020-11-17 10:34:22.888 EST [58881] LOG: 00000: redirecting log output to logging collector process
2020-11-17 10:34:22.888 EST [58881] HINT: Future log output will appear in directory "/postgresql/pgsql/pg_log".
2020-11-17 10:34:22.888 EST [58881] LOCATION: SysLogger_Start, syslogger.c:675
 done
server started
[postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -B /postgresql/pgsql/pg_rman_backups
INFO: copying database files
INFO: copying archived WAL files
INFO: backup complete
INFO: Please execute 'pg_rman validate' to verify the files are correctly copied.
[postgres@node_206 /postgresql/pgsql]$pg_rman validate -B /postgresql/pgsql/pg_rman_backups
INFO: validate: "2020-11-17 23:34:26" backup and archive log files by CRC
INFO: backup "2020-11-17 23:34:26" is valid
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/
=====================================================================
 StartTime      EndTime       Mode  Size  TLI Status
=====================================================================
2020-11-17 23:34:26 2020-11-17 23:34:28 FULL  114MB   6 OK
2020-11-17 23:31:08 2020-11-17 23:31:10 INCR  33MB   6 OK
2020-11-17 23:30:25 2020-11-17 23:30:27 FULL  64MB   6 OK
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$psql
psql (12.3)
Type "help" for help.
postgres=# \l
                 List of databases
  Name  | Owner  | Encoding |  Collate  |  Ctype  |  Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
 postgres | postgres | UTF8   | en_US.UTF-8 | en_US.UTF-8 |
 repmgr  | repmgr  | UTF8   | en_US.UTF-8 | en_US.UTF-8 |
 template0 | postgres | UTF8   | en_US.UTF-8 | en_US.UTF-8 | =c/postgres     +
      |     |     |       |       | postgres=CTc/postgres
 template1 | postgres | UTF8   | en_US.UTF-8 | en_US.UTF-8 | =c/postgres     +
      |     |     |       |       | postgres=CTc/postgres
 test   | postgres | UTF8   | en_US.UTF-8 | en_US.UTF-8 |
(5 rows)
postgres=# \c test
You are now connected to database "test" as user "postgres".
test=# \dt
Did not find any relations.
test=# create table test(id int);
CREATE TABLE
test=# drop table test(id int);
ERROR: syntax error at or near "("
LINE 1: drop table test(id int);
            ^
test=#
test=# \q
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$vim $PGDATA/postgresql.conf
postgres=# \l
                 List of databases
  Name  | Owner  | Encoding |  Collate  |  Ctype  |  Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
 postgres | postgres | UTF8   | en_US.UTF-8 | en_US.UTF-8 |
 repmgr  | repmgr  | UTF8   | en_US.UTF-8 | en_US.UTF-8 |
 template0 | postgres | UTF8   | en_US.UTF-8 | en_US.UTF-8 | =c/postgres     +
      |     |     |       |       | postgres=CTc/postgres
 template1 | postgres | UTF8   | en_US.UTF-8 | en_US.UTF-8 | =c/postgres     +
      |     |     |       |       | postgres=CTc/postgres
 test   | postgres | UTF8   | en_US.UTF-8 | en_US.UTF-8 |
(5 rows)
postgres=# \c test
You are now connected to database "test" as user "postgres".
test=# \dt
Did not find any relations.
test=# create table test(id int);
CREATE TABLE
test=# drop table test(id int);
ERROR: syntax error at or near "("
LINE 1: drop table test(id int);
            ^
test=#
test=# \q
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$vim $PGDATA/postgresql.conf
[postgres@node_206 /postgresql/pgsql]$vim $PGDATA/postgresql.conf
                 List of databases
  Name  | Owner  | Encoding |  Collate  |  Ctype  |  Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
 postgres | postgres | UTF8   | en_US.UTF-8 | en_US.UTF-8 |
 repmgr  | repmgr  | UTF8   | en_US.UTF-8 | en_US.UTF-8 |
 template0 | postgres | UTF8   | en_US.UTF-8 | en_US.UTF-8 | =c/postgres     +
      |     |     |       |       | postgres=CTc/postgres
 template1 | postgres | UTF8   | en_US.UTF-8 | en_US.UTF-8 | =c/postgres     +
      |     |     |       |       | postgres=CTc/postgres
 test   | postgres | UTF8   | en_US.UTF-8 | en_US.UTF-8 |
(5 rows)
postgres=# \c test
You are now connected to database "test" as user "postgres".
test=# \dt
Did not find any relations.
test=# create table test(id int);
CREATE TABLE
test=# drop table test(id int);
ERROR: syntax error at or near "("
LINE 1: drop table test(id int);
            ^
test=#
test=# \q
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$vim $PGDATA/postgresql.conf
[postgres@node_206 /postgresql/pgsql]$vim $PGDATA/postgresql.conf
[postgres@node_206 /postgresql/pgsql]$pg_ctl restart -m fast
waiting for server to shut down.... done
server stopped
waiting for server to start....2020-11-17 10:36:41.191 EST [58933] LOG: 00000: starting PostgreSQL 12.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
2020-11-17 10:36:41.191 EST [58933] LOCATION: PostmasterMain, postmaster.c:998
2020-11-17 10:36:41.192 EST [58933] LOG: 00000: listening on IPv4 address "0.0.0.0", port 5432
2020-11-17 10:36:41.192 EST [58933] LOCATION: StreamServerPort, pqcomm.c:593
2020-11-17 10:36:41.192 EST [58933] LOG: 00000: listening on IPv6 address "::", port 5432
2020-11-17 10:36:41.192 EST [58933] LOCATION: StreamServerPort, pqcomm.c:593
2020-11-17 10:36:41.197 EST [58933] LOG: 00000: listening on Unix socket "/tmp/.s.PGSQL.5432"
2020-11-17 10:36:41.197 EST [58933] LOCATION: StreamServerPort, pqcomm.c:587
2020-11-17 10:36:41.229 EST [58933] LOG: 00000: redirecting log output to logging collector process
2020-11-17 10:36:41.229 EST [58933] HINT: Future log output will appear in directory "/postgresql/pgsql/pg_log".
2020-11-17 10:36:41.229 EST [58933] LOCATION: SysLogger_Start, syslogger.c:675
 done
server started
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$ll
total 28
drwxr-xr-x. 2 postgres postgres 4096 Nov 17 23:36 archive_log
drwxrwxr-x. 2 postgres postgres  6 Nov 17 15:51 backups
drwxr-xr-x. 2 postgres postgres 4096 Nov 17 16:43 bin
drwx------. 19 postgres postgres 4096 Nov 17 23:36 data
drwxr-xr-x. 6 postgres postgres 4096 Nov 15 16:14 include
drwxr-xr-x. 4 postgres postgres 4096 Nov 17 06:37 lib
drwxr-xr-x. 2 postgres postgres 4096 Nov 17 23:36 pg_log
drwxrwxr-x. 5 postgres postgres 104 Nov 17 23:30 pg_rman_backups
drwxr-xr-x. 8 postgres postgres 4096 Nov 15 16:14 share
[postgres@node_206 /postgresql/pgsql]$rm -rf archive_log/*
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$rm -rf pg_rman_backups/*
[postgres@node_206 /postgresql/pgsql]$ll
total 24
drwxr-xr-x. 2 postgres postgres  6 Nov 17 23:36 archive_log
drwxrwxr-x. 2 postgres postgres  6 Nov 17 15:51 backups
drwxr-xr-x. 2 postgres postgres 4096 Nov 17 16:43 bin
drwx------. 19 postgres postgres 4096 Nov 17 23:36 data
drwxr-xr-x. 6 postgres postgres 4096 Nov 15 16:14 include
drwxr-xr-x. 4 postgres postgres 4096 Nov 17 06:37 lib
drwxr-xr-x. 2 postgres postgres 4096 Nov 17 23:36 pg_log
drwxrwxr-x. 2 postgres postgres  6 Nov 17 23:36 pg_rman_backups
drwxr-xr-x. 8 postgres postgres 4096 Nov 15 16:14 share
[postgres@node_206 /postgresql/pgsql]$pwd
/postgresql/pgsql
[postgres@node_206 /postgresql/pgsql]$ls
archive_log backups bin data include lib pg_log pg_rman_backups share
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$ll
total 24
drwxr-xr-x. 2 postgres postgres  6 Nov 17 23:36 archive_log
drwxrwxr-x. 2 postgres postgres  6 Nov 17 15:51 backups
drwxr-xr-x. 2 postgres postgres 4096 Nov 17 16:43 bin
drwx------. 19 postgres postgres 4096 Nov 17 23:36 data
drwxr-xr-x. 6 postgres postgres 4096 Nov 15 16:14 include
drwxr-xr-x. 4 postgres postgres 4096 Nov 17 06:37 lib
drwxr-xr-x. 2 postgres postgres 4096 Nov 17 23:36 pg_log
drwxrwxr-x. 2 postgres postgres  6 Nov 17 23:36 pg_rman_backups
drwxr-xr-x. 8 postgres postgres 4096 Nov 15 16:14 share
[postgres@node_206 /postgresql/pgsql]$pwd
/postgresql/pgsql
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$vim $PGDATA/postgresql.conf
total 24
drwxr-xr-x. 2 postgres postgres  6 Nov 17 23:36 archive_log
drwxrwxr-x. 2 postgres postgres  6 Nov 17 15:51 backups
drwxr-xr-x. 2 postgres postgres 4096 Nov 17 16:43 bin
drwx------. 19 postgres postgres 4096 Nov 17 23:36 data
drwxr-xr-x. 6 postgres postgres 4096 Nov 15 16:14 include
drwxr-xr-x. 4 postgres postgres 4096 Nov 17 06:37 lib
drwxr-xr-x. 2 postgres postgres 4096 Nov 17 23:36 pg_log
drwxrwxr-x. 2 postgres postgres  6 Nov 17 23:36 pg_rman_backups
drwxr-xr-x. 8 postgres postgres 4096 Nov 15 16:14 share
[postgres@node_206 /postgresql/pgsql]$pwd
/postgresql/pgsql
[postgres@node_206 /postgresql/pgsql]$ls
archive_log backups bin data include lib pg_log pg_rman_backups share
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$ll
total 24
drwxr-xr-x. 2 postgres postgres  6 Nov 17 23:36 archive_log
drwxrwxr-x. 2 postgres postgres  6 Nov 17 15:51 backups
drwxr-xr-x. 2 postgres postgres 4096 Nov 17 16:43 bin
drwx------. 19 postgres postgres 4096 Nov 17 23:36 data
drwxr-xr-x. 6 postgres postgres 4096 Nov 15 16:14 include
drwxr-xr-x. 4 postgres postgres 4096 Nov 17 06:37 lib
drwxr-xr-x. 2 postgres postgres 4096 Nov 17 23:36 pg_log
drwxrwxr-x. 2 postgres postgres  6 Nov 17 23:36 pg_rman_backups
drwxr-xr-x. 8 postgres postgres 4096 Nov 15 16:14 share
[postgres@node_206 /postgresql/pgsql]$pwd
/postgresql/pgsql
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$vim $PGDATA/postgresql.conf
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$tail -3  $PGDATA/postgresql.conf
#for pg_Rman
archive_mode = on # enables archiving; off, on, or always
archive_command = 'test ! -f /postgresql/pgsql/archive_log/%f && cp %p /postgresql/pgsql/archive_log/%f'
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_ctl restart -m fast
waiting for server to shut down.... done
server stopped
waiting for server to start....2020-11-17 10:45:13.636 EST [59035] LOG: 00000: starting PostgreSQL 12.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
2020-11-17 10:45:13.636 EST [59035] LOCATION: PostmasterMain, postmaster.c:998
2020-11-17 10:45:13.638 EST [59035] LOG: 00000: listening on IPv4 address "0.0.0.0", port 5432
2020-11-17 10:45:13.638 EST [59035] LOCATION: StreamServerPort, pqcomm.c:593
2020-11-17 10:45:13.638 EST [59035] LOG: 00000: listening on IPv6 address "::", port 5432
2020-11-17 10:45:13.638 EST [59035] LOCATION: StreamServerPort, pqcomm.c:593
2020-11-17 10:45:13.644 EST [59035] LOG: 00000: listening on Unix socket "/tmp/.s.PGSQL.5432"
2020-11-17 10:45:13.644 EST [59035] LOCATION: StreamServerPort, pqcomm.c:587
2020-11-17 10:45:13.696 EST [59035] LOG: 00000: redirecting log output to logging collector process
2020-11-17 10:45:13.696 EST [59035] HINT: Future log output will appear in directory "/postgresql/pgsql/pg_log".
2020-11-17 10:45:13.696 EST [59035] LOCATION: SysLogger_Start, syslogger.c:675
 done
server started
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$ll
total 24
drwxr-xr-x. 2 postgres postgres  6 Nov 17 23:36 archive_log
drwxrwxr-x. 2 postgres postgres  6 Nov 17 15:51 backups
drwxr-xr-x. 2 postgres postgres 4096 Nov 17 16:43 bin
drwx------. 19 postgres postgres 4096 Nov 17 23:45 data
drwxr-xr-x. 6 postgres postgres 4096 Nov 15 16:14 include
drwxr-xr-x. 4 postgres postgres 4096 Nov 17 06:37 lib
drwxr-xr-x. 2 postgres postgres 4096 Nov 17 23:45 pg_log
drwxrwxr-x. 2 postgres postgres  6 Nov 17 23:36 pg_rman_backups
drwxr-xr-x. 8 postgres postgres 4096 Nov 15 16:14 share
[postgres@node_206 /postgresql/pgsql]$pg_rman init -B /postgresql/pgsql/pg_rman_backups/
INFO: ARCLOG_PATH is set to '/postgresql/pgsql/archive_log'
INFO: SRVLOG_PATH is set to '/postgresql/pgsql/pg_log'
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$psql
psql (12.3)
Type "help" for help.
postgres=# \l
                 List of databases
  Name  | Owner  | Encoding |  Collate  |  Ctype  |  Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
 postgres | postgres | UTF8   | en_US.UTF-8 | en_US.UTF-8 |
 repmgr  | repmgr  | UTF8   | en_US.UTF-8 | en_US.UTF-8 |
 template0 | postgres | UTF8   | en_US.UTF-8 | en_US.UTF-8 | =c/postgres     +
      |     |     |       |       | postgres=CTc/postgres
 template1 | postgres | UTF8   | en_US.UTF-8 | en_US.UTF-8 | =c/postgres     +
      |     |     |       |       | postgres=CTc/postgres
 test   | postgres | UTF8   | en_US.UTF-8 | en_US.UTF-8 |
(5 rows)
postgres=# \c test
You are now connected to database "test" as user "postgres".
test=# \dt
    List of relations
 Schema | Name | Type | Owner 
--------+------+-------+----------
 public | test | table | postgres
(1 row)
test=# drop table test
test-# ;
DROP TABLE
test=# create table test(id int, crt_time timestamp);
CREATE TABLE
test=# insert into test(id) select n from generate_series(1,100) n;
INSERT 0 100
test=# \q
[postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -B /postgresql/pgsql/pg_rman_backups
INFO: copying database files
INFO: copying archived WAL files
INFO: backup complete
INFO: Please execute 'pg_rman validate' to verify the files are correctly copied.
[postgres@node_206 /postgresql/pgsql]$pg_rman validate -B /postgresql/pgsql/pg_rman_backups
INFO: validate: "2020-11-17 23:46:22" backup and archive log files by CRC
INFO: backup "2020-11-17 23:46:22" is valid
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$psql
psql (12.3)
Type "help" for help.
postgres=# \c test
You are now connected to database "test" as user "postgres".
test=# select * from test;
 id | crt_time
-----+----------
  1 |
  2 |
  3 |
  4 |
  5 |
  6 |
  7 |
  8 |
  9 |
 10 |
 11 |
 12 |
 13 |
 14 |
 15 |
 16 |
 17 |
 18 |
 19 |
 20 |
 21 |
 22 |
 23 |
 24 |
 25 |
 26 |
 27 |
 28 |
 29 |
 30 |
 31 |
 32 |
 33 |
 34 |
 35 |
 36 |
 37 |
 38 |
 39 |
 40 |
 41 |
 42 |
 43 |
 44 |
 45 |
 46 |
 47 |
 48 |
 49 |
 50 |
 51 |
 52 |
 53 |
 54 |
 55 |
 56 |
 57 |
 58 |
 59 |
 60 |
 61 |
 62 |
 63 |
 64 |
 65 |
 66 |
 67 |
 68 |
 69 |
 70 |
 71 |
 72 |
 73 |
 74 |
 75 |
 76 |
 77 |
 78 |
 79 |
 80 |
 81 |
 82 |
 83 |
 84 |
 85 |
 86 |
 87 |
 88 |
 89 |
 90 |
 91 |
 92 |
 93 |
 94 |
 95 |
 96 |
 97 |
 98 |
 99 |
 100 |
(100 rows)
test=#
test=#
test=#
test=#
test=#
test=#
test=#
test=#
test=#
test=# insert into test (id) select n from generate_series(101,110) n;
INSERT 0 10
test=# \q
[postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=incremental -B /postgresql/pgsql/pg_rman_backups
INFO: copying database files
INFO: copying archived WAL files
INFO: backup complete
INFO: Please execute 'pg_rman validate' to verify the files are correctly copied.
[postgres@node_206 /postgresql/pgsql]$pg_rman validate -B /postgresql/pgsql/pg_rman_backups
INFO: validate: "2020-11-17 23:47:09" backup and archive log files by CRC
INFO: backup "2020-11-17 23:47:09" is valid
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/
=====================================================================
 StartTime      EndTime       Mode  Size  TLI Status
=====================================================================
2020-11-17 23:47:09 2020-11-17 23:47:12 INCR  33MB   6 OK
2020-11-17 23:46:22 2020-11-17 23:46:24 FULL  64MB   6 OK
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$psql -d test
psql (12.3)
Type "help" for help.
test=# create table test2( like test );
CREATE TABLE
test=# insert into test2(id) select n from generate_serires(1,100) n;
ERROR: function generate_serires(integer, integer) does not exist
LINE 1: insert into test2(id) select n from generate_serires(1,100) ...
                      ^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
test=#
test=# insert into test2(id) select n from generate_series(1,100) n;
INSERT 0 100
test=# \q
[postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -B /postgresql/pgsql/pg_rman_backups
INFO: copying database files
INFO: copying archived WAL files
INFO: backup complete
INFO: Please execute 'pg_rman validate' to verify the files are correctly copied.
[postgres@node_206 /postgresql/pgsql]$pg_rman validate -B /postgresql/pgsql/pg_rman_backups
INFO: validate: "2020-11-17 23:49:32" backup and archive log files by CRC
INFO: backup "2020-11-17 23:49:32" is valid
[postgres@node_206 /postgresql/pgsql]$psql -d test
psql (12.3)
Type "help" for help.
test=# insert into test(id) select n from generate_series(101,100) n;
INSERT 0 0
test=# \q
[postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=incremental -B /postgresql/pgsql/pg_rman_backups
INFO: copying database files
INFO: copying archived WAL files
INFO: backup complete
INFO: Please execute 'pg_rman validate' to verify the files are correctly copied.
[postgres@node_206 /postgresql/pgsql]$pg_rman validate -B /postgresql/pgsql/pg_rman_backups
INFO: validate: "2020-11-17 23:49:59" backup and archive log files by CRC
INFO: backup "2020-11-17 23:49:59" is valid
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/
=====================================================================
 StartTime      EndTime       Mode  Size  TLI Status
=====================================================================
2020-11-17 23:49:59 2020-11-17 23:50:01 INCR  33MB   6 OK
2020-11-17 23:49:32 2020-11-17 23:49:35 FULL  64MB   6 OK
2020-11-17 23:47:09 2020-11-17 23:47:12 INCR  33MB   6 OK
2020-11-17 23:46:22 2020-11-17 23:46:24 FULL  64MB   6 OK
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_rman delete 2020-11-17 23:47:09 -B /postgresql/pgsql/pg_rman_backups/
WARNING: cannot delete backup with start time "2020-11-17 23:47:09"
DETAIL: This is the incremental backup necessary for successful recovery.
WARNING: cannot delete backup with start time "2020-11-17 23:46:22"
DETAIL: This is the latest full backup necessary for successful recovery.
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/
=====================================================================
 StartTime      EndTime       Mode  Size  TLI Status
=====================================================================
2020-11-17 23:49:59 2020-11-17 23:50:01 INCR  33MB   6 OK
2020-11-17 23:49:32 2020-11-17 23:49:35 FULL  64MB   6 OK
2020-11-17 23:47:09 2020-11-17 23:47:12 INCR  33MB   6 OK
2020-11-17 23:46:22 2020-11-17 23:46:24 FULL  64MB   6 OK
[postgres@node_206 /postgresql/pgsql]$pg_rman delete -f 2020-11-17 23:47:09 -B /postgresql/pgsql/pg_rman_backups/
WARNING: using force option will make some of the remaining backups unusable
DETAIL: Any remaining incremental backups that are older than the oldest available full backup cannot be restored.
INFO: delete the backup with start time: "2020-11-17 23:47:09"
INFO: delete the backup with start time: "2020-11-17 23:46:22"
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$ll pg_rman_backups/
total 8
drwx------. 6 postgres postgres 62 Nov 17 23:49 20201117
drwx------. 4 postgres postgres 34 Nov 17 23:45 backup
-rw-rw-r--. 1 postgres postgres 84 Nov 17 23:45 pg_rman.ini
-rw-rw-r--. 1 postgres postgres 40 Nov 17 23:45 system_identifier
drwx------. 2 postgres postgres 6 Nov 17 23:45 timeline_history
[postgres@node_206 /postgresql/pgsql]$ll pg_rman_backups/20201117/
total 0
drwx------. 2 postgres postgres 89 Nov 17 23:50 234622
drwx------. 2 postgres postgres 89 Nov 17 23:50 234709
drwx------. 5 postgres postgres 133 Nov 17 23:49 234932
drwx------. 5 postgres postgres 133 Nov 17 23:50 234959
[postgres@node_206 /postgresql/pgsql]$ll pg_rman_backups/20201117/234622/
total 112
-rw-rw-r--. 1 postgres postgres  433 Nov 17 23:50 backup.ini
-rw-rw-r--. 1 postgres postgres  226 Nov 17 23:46 file_arclog.txt
-rw-rw-r--. 1 postgres postgres 99521 Nov 17 23:46 file_database.txt
-rwx------. 1 postgres postgres  764 Nov 17 23:46 mkdirs.sh
[postgres@node_206 /postgresql/pgsql]$ll pg_rman_backups/20201117/2347
ls: cannot access pg_rman_backups/20201117/2347: No such file or directory
[postgres@node_206 /postgresql/pgsql]$ll pg_rman_backups/20201117/234709/
total 124
-rw-rw-r--. 1 postgres postgres  438 Nov 17 23:50 backup.ini
-rw-rw-r--. 1 postgres postgres  468 Nov 17 23:47 file_arclog.txt
-rw-rw-r--. 1 postgres postgres 113305 Nov 17 23:47 file_database.txt
-rwx------. 1 postgres postgres  764 Nov 17 23:47 mkdirs.sh
[postgres@node_206 /postgresql/pgsql]$ll pg_rman_backups/20201117/234932/
total 116
drwx------. 2 postgres postgres  118 Nov 17 23:49 arclog
-rw-rw-r--. 1 postgres postgres  428 Nov 17 23:49 backup.ini
drwx------. 19 postgres postgres 4096 Nov 17 23:49 database
-rw-rw-r--. 1 postgres postgres  708 Nov 17 23:49 file_arclog.txt
-rw-rw-r--. 1 postgres postgres 99583 Nov 17 23:49 file_database.txt
-rwx------. 1 postgres postgres  764 Nov 17 23:49 mkdirs.sh
drwx------. 2 postgres postgres   6 Nov 17 23:49 srvlog
[postgres@node_206 /postgresql/pgsql]$pg_rman purge
ERROR: required parameter not specified: BACKUP_PATH (-B, --backup-path)
[postgres@node_206 /postgresql/pgsql]$pg_rman purge -B /postgresql/pgsql/pg_rman_backups/
INFO: DELETED backup "2020-11-17 23:47:09" is purged
INFO: DELETED backup "2020-11-17 23:46:22" is purged
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$ll pg_rman_backups/20201117/234622/
ls: cannot access pg_rman_backups/20201117/234622/: No such file or directory
[postgres@node_206 /postgresql/pgsql]$ll pg_rman_backups/20201117
total 0
drwx------. 5 postgres postgres 133 Nov 17 23:49 234932
drwx------. 5 postgres postgres 133 Nov 17 23:50 234959
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/
=====================================================================
 StartTime      EndTime       Mode  Size  TLI Status
=====================================================================
2020-11-17 23:49:59 2020-11-17 23:50:01 INCR  33MB   6 OK
2020-11-17 23:49:32 2020-11-17 23:49:35 FULL  64MB   6 OK
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$psql
psql (12.3)
Type "help" for help.
postgres=# drop database test;
DROP DATABASE
postgres=# \q
[postgres@node_206 /postgresql/pgsql]$pg_ctl stop -m fast
waiting for server to shut down.... done
server stopped
[postgres@node_206 /postgresql/pgsql]$pg_rman restore -B /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-11-17 23:49:32'
ERROR: cannot do restore
DETAIL: There is no valid full backup which can be used for given recovery condition.
[postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -B /postgresql/pgsql/pg_rman_backups
ERROR: could not connect to database postgres: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_ctl start
waiting for server to start....2020-11-17 10:53:41.927 EST [59212] LOG: 00000: starting PostgreSQL 12.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
2020-11-17 10:53:41.927 EST [59212] LOCATION: PostmasterMain, postmaster.c:998
2020-11-17 10:53:41.928 EST [59212] LOG: 00000: listening on IPv4 address "0.0.0.0", port 5432
2020-11-17 10:53:41.928 EST [59212] LOCATION: StreamServerPort, pqcomm.c:593
2020-11-17 10:53:41.928 EST [59212] LOG: 00000: listening on IPv6 address "::", port 5432
2020-11-17 10:53:41.928 EST [59212] LOCATION: StreamServerPort, pqcomm.c:593
2020-11-17 10:53:41.929 EST [59212] LOG: 00000: listening on Unix socket "/tmp/.s.PGSQL.5432"
2020-11-17 10:53:41.929 EST [59212] LOCATION: StreamServerPort, pqcomm.c:587
2020-11-17 10:53:41.977 EST [59212] LOG: 00000: redirecting log output to logging collector process
2020-11-17 10:53:41.977 EST [59212] HINT: Future log output will appear in directory "/postgresql/pgsql/pg_log".
2020-11-17 10:53:41.977 EST [59212] LOCATION: SysLogger_Start, syslogger.c:675
 done
server started
[postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -B /postgresql/pgsql/pg_rman_backups
INFO: copying database files
INFO: copying archived WAL files
INFO: backup complete
INFO: Please execute 'pg_rman validate' to verify the files are correctly copied.
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_rman validate -B /postgresql/pgsql/pg_rman_backups
INFO: validate: "2020-11-17 23:53:43" backup and archive log files by CRC
INFO: backup "2020-11-17 23:53:43" is valid
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/
=====================================================================
 StartTime      EndTime       Mode  Size  TLI Status
=====================================================================
2020-11-17 23:53:43 2020-11-17 23:53:45 FULL  75MB   6 OK
2020-11-17 23:53:39 2020-11-17 23:53:39 FULL   0B   0 ERROR
2020-11-17 23:49:59 2020-11-17 23:50:01 INCR  33MB   6 OK
2020-11-17 23:49:32 2020-11-17 23:49:35 FULL  64MB   6 OK
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$psql -d test
psql: error: could not connect to server: FATAL: database "test" does not exist
[postgres@node_206 /postgresql/pgsql]$psql
psql (12.3)
Type "help" for help.
postgres=# create database test;
CREATE DATABASE
postgres=# \c test
You are now connected to database "test" as user "postgres".
test=# create table test2(id int, crt_time timestamp );
CREATE TABLE
test=# insert into test2(id) select n from generate_series(1,100) n;
INSERT 0 100
test=#
test=# \q
[postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -B /postgresql/pgsql/pg_rman_backups
INFO: copying database files
INFO: copying archived WAL files
INFO: backup complete
INFO: Please execute 'pg_rman validate' to verify the files are correctly copied.
[postgres@node_206 /postgresql/pgsql]$pg_rman validate -B /postgresql/pgsql/pg_rman_backups
INFO: validate: "2020-11-17 23:58:53" backup and archive log files by CRC
INFO: backup "2020-11-17 23:58:53" is valid
[postgres@node_206 /postgresql/pgsql]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/
=====================================================================
 StartTime      EndTime       Mode  Size  TLI Status
=====================================================================
2020-11-17 23:58:53 2020-11-17 23:58:55 FULL  64MB   6 OK
2020-11-17 23:53:43 2020-11-17 23:53:45 FULL  75MB   6 OK
2020-11-17 23:53:39 2020-11-17 23:53:39 FULL   0B   0 ERROR
2020-11-17 23:49:59 2020-11-17 23:50:01 INCR  33MB   6 OK
2020-11-17 23:49:32 2020-11-17 23:49:35 FULL  64MB   6 OK
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_rman delete -f 2020-11-17 23:53:39 -B /postgresql/pgsql/pg_rman_backups/
WARNING: using force option will make some of the remaining backups unusable
DETAIL: Any remaining incremental backups that are older than the oldest available full backup cannot be restored.
INFO: delete the backup with start time: "2020-11-17 23:53:39"
INFO: delete the backup with start time: "2020-11-17 23:49:59"
INFO: delete the backup with start time: "2020-11-17 23:49:32"
[postgres@node_206 /postgresql/pgsql]$pg_rman purge -B /postgresql/pgsql/pg_rman_backups/
INFO: DELETED backup "2020-11-17 23:53:39" is purged
INFO: DELETED backup "2020-11-17 23:49:59" is purged
INFO: DELETED backup "2020-11-17 23:49:32" is purged
[postgres@node_206 /postgresql/pgsql]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/
=====================================================================
 StartTime      EndTime       Mode  Size  TLI Status
=====================================================================
2020-11-17 23:58:53 2020-11-17 23:58:55 FULL  64MB   6 OK
2020-11-17 23:53:43 2020-11-17 23:53:45 FULL  75MB   6 OK
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$psql
psql (12.3)
Type "help" for help.
postgres=# \c test
You are now connected to database "test" as user "postgres".
test=# \dt
     List of relations
 Schema | Name | Type | Owner 
--------+-------+-------+----------
 public | test2 | table | postgres
(1 row)
test=# \c postgres
You are now connected to database "postgres" as user "postgres".
postgres=# drop database test;
DROP DATABASE
postgres=# \q
[postgres@node_206 /postgresql/pgsql]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/
=====================================================================
 StartTime      EndTime       Mode  Size  TLI Status
=====================================================================
2020-11-17 23:58:53 2020-11-17 23:58:55 FULL  64MB   6 OK
2020-11-17 23:53:43 2020-11-17 23:53:45 FULL  75MB   6 OK
[postgres@node_206 /postgresql/pgsql]$pg_rman restore -B /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-11-17 23:58:53'
ERROR: PostgreSQL server is running
HINT: Please stop PostgreSQL server before executing restore.
[postgres@node_206 /postgresql/pgsql]$pg_ctl stop -m fast
waiting for server to shut down.... done
server stopped
[postgres@node_206 /postgresql/pgsql]$pg_rman restore -B /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-11-17 23:58:53'
INFO: the recovery target timeline ID is not given
INFO: use timeline ID of current database cluster as recovery target: 6
INFO: calculating timeline branches to be used to recovery target point
INFO: searching latest full backup which can be used as restore start point
INFO: found the full backup can be used as base in recovery: "2020-11-17 23:53:43"
INFO: copying online WAL files and server log files
INFO: clearing restore destination
INFO: validate: "2020-11-17 23:53:43" backup and archive log files by SIZE
INFO: backup "2020-11-17 23:53:43" is valid
INFO: restoring database files from the full mode backup "2020-11-17 23:53:43"
INFO: searching incremental backup to be restored
INFO: searching backup which contained archived WAL files to be restored
INFO: backup "2020-11-17 23:53:43" is valid
INFO: restoring WAL files from backup "2020-11-17 23:53:43"
INFO: backup "2020-11-17 23:58:53" is valid
INFO: restoring WAL files from backup "2020-11-17 23:58:53"
INFO: restoring online WAL files and server log files
INFO: add recovery related options to postgresql.conf
INFO: generating recovery.signal
INFO: restore complete
HINT: Recovery will start automatically when the PostgreSQL server is started.
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -B /postgresql/pgsql/pg_rman_backups
ERROR: could not connect to database postgres: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
[postgres@node_206 /postgresql/pgsql]$pg_ctl start
waiting for server to start....2020-11-17 11:00:30.910 EST [59357] LOG: 00000: starting PostgreSQL 12.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
2020-11-17 11:00:30.910 EST [59357] LOCATION: PostmasterMain, postmaster.c:998
2020-11-17 11:00:30.910 EST [59357] LOG: 00000: listening on IPv4 address "0.0.0.0", port 5432
2020-11-17 11:00:30.910 EST [59357] LOCATION: StreamServerPort, pqcomm.c:593
2020-11-17 11:00:30.910 EST [59357] LOG: 00000: listening on IPv6 address "::", port 5432
2020-11-17 11:00:30.910 EST [59357] LOCATION: StreamServerPort, pqcomm.c:593
2020-11-17 11:00:30.914 EST [59357] LOG: 00000: listening on Unix socket "/tmp/.s.PGSQL.5432"
2020-11-17 11:00:30.914 EST [59357] LOCATION: StreamServerPort, pqcomm.c:587
2020-11-17 11:00:30.965 EST [59357] LOG: 00000: redirecting log output to logging collector process
2020-11-17 11:00:30.965 EST [59357] HINT: Future log output will appear in directory "/postgresql/pgsql/pg_log".
2020-11-17 11:00:30.965 EST [59357] LOCATION: SysLogger_Start, syslogger.c:675
 done
server started
[postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -B /postgresql/pgsql/pg_rman_backups
INFO: copying database files
ERROR: query failed: ERROR: recovery is in progress
HINT: pg_walfile_name_offset() cannot be executed during recovery.
query was: SELECT * from pg_walfile_name_offset(pg_start_backup($1, $2, $3))
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$rm -f data/recovery.signal
[postgres@node_206 /postgresql/pgsql]$pg_ctl restart -m fast
waiting for server to shut down.... done
server stopped
waiting for server to start....2020-11-17 11:00:51.204 EST [59374] LOG: 00000: starting PostgreSQL 12.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
2020-11-17 11:00:51.204 EST [59374] LOCATION: PostmasterMain, postmaster.c:998
2020-11-17 11:00:51.205 EST [59374] LOG: 00000: listening on IPv4 address "0.0.0.0", port 5432
2020-11-17 11:00:51.205 EST [59374] LOCATION: StreamServerPort, pqcomm.c:593
2020-11-17 11:00:51.205 EST [59374] LOG: 00000: listening on IPv6 address "::", port 5432
2020-11-17 11:00:51.205 EST [59374] LOCATION: StreamServerPort, pqcomm.c:593
2020-11-17 11:00:51.210 EST [59374] LOG: 00000: listening on Unix socket "/tmp/.s.PGSQL.5432"
2020-11-17 11:00:51.210 EST [59374] LOCATION: StreamServerPort, pqcomm.c:587
2020-11-17 11:00:51.270 EST [59374] LOG: 00000: redirecting log output to logging collector process
2020-11-17 11:00:51.270 EST [59374] HINT: Future log output will appear in directory "/postgresql/pgsql/pg_log".
2020-11-17 11:00:51.270 EST [59374] LOCATION: SysLogger_Start, syslogger.c:675
 done
server started
[postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -B /postgresql/pgsql/pg_rman_backups
INFO: copying database files
INFO: copying archived WAL files
INFO: backup complete
INFO: Please execute 'pg_rman validate' to verify the files are correctly copied.
[postgres@node_206 /postgresql/pgsql]$pg_rman validate -B /postgresql/pgsql/pg_rman_backups
INFO: validate: "2020-11-18 00:00:53" backup and archive log files by CRC
INFO: backup "2020-11-18 00:00:53" is valid
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/
=====================================================================
 StartTime      EndTime       Mode  Size  TLI Status
=====================================================================
2020-11-18 00:00:53 2020-11-18 00:00:55 FULL  159MB   6 OK
2020-11-18 00:00:34 2020-11-18 00:00:34 FULL   0B   0 ERROR
2020-11-18 00:00:26 2020-11-18 00:00:26 FULL   0B   0 ERROR
2020-11-17 23:58:53 2020-11-17 23:58:55 FULL  64MB   6 OK
2020-11-17 23:53:43 2020-11-17 23:53:45 FULL  75MB   6 OK
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$psql
psql (12.3)
Type "help" for help.
postgres=# \l
                 List of databases
  Name  | Owner  | Encoding |  Collate  |  Ctype  |  Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
 postgres | postgres | UTF8   | en_US.UTF-8 | en_US.UTF-8 |
 repmgr  | repmgr  | UTF8   | en_US.UTF-8 | en_US.UTF-8 |
 template0 | postgres | UTF8   | en_US.UTF-8 | en_US.UTF-8 | =c/postgres     +
      |     |     |       |       | postgres=CTc/postgres
 template1 | postgres | UTF8   | en_US.UTF-8 | en_US.UTF-8 | =c/postgres     +
      |     |     |       |       | postgres=CTc/postgres
(4 rows)
postgres=# \c test
FATAL: database "test" does not exist
Previous connection kept
postgres=# \q
[postgres@node_206 /postgresql/pgsql]$vim $PGDATA/postgresql.conf
[postgres@node_206 /postgresql/pgsql]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/
=====================================================================
 StartTime      EndTime       Mode  Size  TLI Status
=====================================================================
2020-11-18 00:00:53 2020-11-18 00:00:55 FULL  159MB   6 OK
2020-11-18 00:00:34 2020-11-18 00:00:34 FULL   0B   0 ERROR
2020-11-18 00:00:26 2020-11-18 00:00:26 FULL   0B   0 ERROR
2020-11-17 23:58:53 2020-11-17 23:58:55 FULL  64MB   6 OK
2020-11-17 23:53:43 2020-11-17 23:53:45 FULL  75MB   6 OK
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$psql
psql (12.3)
Type "help" for help.
postgres=# \l
                 List of databases
  Name  | Owner  | Encoding |  Collate  |  Ctype  |  Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
 postgres | postgres | UTF8   | en_US.UTF-8 | en_US.UTF-8 |
 repmgr  | repmgr  | UTF8   | en_US.UTF-8 | en_US.UTF-8 |
 template0 | postgres | UTF8   | en_US.UTF-8 | en_US.UTF-8 | =c/postgres     +
      |     |     |       |       | postgres=CTc/postgres
 template1 | postgres | UTF8   | en_US.UTF-8 | en_US.UTF-8 | =c/postgres     +
      |     |     |       |       | postgres=CTc/postgres
(4 rows)
postgres=# \c test
FATAL: database "test" does not exist
Previous connection kept
postgres=# \q
[postgres@node_206 /postgresql/pgsql]$vim $PGDATA/postgresql.conf
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_ctl restart -m fast
waiting for server to shut down.... done
server stopped
waiting for server to start....2020-11-17 11:01:30.816 EST [59423] LOG: 00000: starting PostgreSQL 12.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
2020-11-17 11:01:30.816 EST [59423] LOCATION: PostmasterMain, postmaster.c:998
2020-11-17 11:01:30.822 EST [59423] LOG: 00000: listening on IPv4 address "0.0.0.0", port 5432
2020-11-17 11:01:30.822 EST [59423] LOCATION: StreamServerPort, pqcomm.c:593
2020-11-17 11:01:30.822 EST [59423] LOG: 00000: listening on IPv6 address "::", port 5432
2020-11-17 11:01:30.822 EST [59423] LOCATION: StreamServerPort, pqcomm.c:593
2020-11-17 11:01:30.837 EST [59423] LOG: 00000: listening on Unix socket "/tmp/.s.PGSQL.5432"
2020-11-17 11:01:30.837 EST [59423] LOCATION: StreamServerPort, pqcomm.c:587
2020-11-17 11:01:30.877 EST [59423] LOG: 00000: redirecting log output to logging collector process
2020-11-17 11:01:30.877 EST [59423] HINT: Future log output will appear in directory "/postgresql/pgsql/pg_log".
2020-11-17 11:01:30.877 EST [59423] LOCATION: SysLogger_Start, syslogger.c:675
 done
server started
[postgres@node_206 /postgresql/pgsql]$ll
total 28
drwxr-xr-x. 2 postgres postgres 4096 Nov 18 00:01 archive_log
drwxrwxr-x. 2 postgres postgres  6 Nov 17 15:51 backups
drwxr-xr-x. 2 postgres postgres 4096 Nov 17 16:43 bin
drwx------. 19 postgres postgres 4096 Nov 18 00:01 data
drwxr-xr-x. 6 postgres postgres 4096 Nov 15 16:14 include
drwxr-xr-x. 4 postgres postgres 4096 Nov 17 06:37 lib
drwxr-xr-x. 2 postgres postgres 4096 Nov 18 00:01 pg_log
drwxrwxr-x. 6 postgres postgres 120 Nov 18 00:00 pg_rman_backups
drwxr-xr-x. 8 postgres postgres 4096 Nov 15 16:14 share
[postgres@node_206 /postgresql/pgsql]$rm -rf archive_log/* pg_rman_backups/*
[postgres@node_206 /postgresql/pgsql]$ll
total 24
drwxr-xr-x. 2 postgres postgres  6 Nov 18 00:01 archive_log
drwxrwxr-x. 2 postgres postgres  6 Nov 17 15:51 backups
drwxr-xr-x. 2 postgres postgres 4096 Nov 17 16:43 bin
drwx------. 19 postgres postgres 4096 Nov 18 00:01 data
drwxr-xr-x. 6 postgres postgres 4096 Nov 15 16:14 include
drwxr-xr-x. 4 postgres postgres 4096 Nov 17 06:37 lib
drwxr-xr-x. 2 postgres postgres 4096 Nov 18 00:01 pg_log
drwxrwxr-x. 2 postgres postgres  6 Nov 18 00:01 pg_rman_backups
drwxr-xr-x. 8 postgres postgres 4096 Nov 15 16:14 share
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$ls
archive_log backups bin data include lib pg_log pg_rman_backups share
[postgres@node_206 /postgresql/pgsql]$ll
total 24
drwxr-xr-x. 2 postgres postgres  6 Nov 18 00:01 archive_log
drwxrwxr-x. 2 postgres postgres  6 Nov 17 15:51 backups
drwxr-xr-x. 2 postgres postgres 4096 Nov 17 16:43 bin
drwx------. 19 postgres postgres 4096 Nov 18 00:01 data
drwxr-xr-x. 6 postgres postgres 4096 Nov 15 16:14 include
drwxr-xr-x. 4 postgres postgres 4096 Nov 17 06:37 lib
drwxr-xr-x. 2 postgres postgres 4096 Nov 18 00:01 pg_log
drwxrwxr-x. 2 postgres postgres  6 Nov 18 00:01 pg_rman_backups
drwxr-xr-x. 8 postgres postgres 4096 Nov 15 16:14 share
[postgres@node_206 /postgresql/pgsql]$ll pg_rman_backups/
total 0
[postgres@node_206 /postgresql/pgsql]$ll archive_log/
total 0
[postgres@node_206 /postgresql/pgsql]$ll
total 24
drwxr-xr-x. 2 postgres postgres  6 Nov 18 00:01 archive_log
drwxrwxr-x. 2 postgres postgres  6 Nov 17 15:51 backups
drwxr-xr-x. 2 postgres postgres 4096 Nov 17 16:43 bin
drwx------. 19 postgres postgres 4096 Nov 18 00:01 data
drwxr-xr-x. 6 postgres postgres 4096 Nov 15 16:14 include
drwxr-xr-x. 4 postgres postgres 4096 Nov 17 06:37 lib
drwxr-xr-x. 2 postgres postgres 4096 Nov 18 00:01 pg_log
drwxrwxr-x. 2 postgres postgres  6 Nov 18 00:01 pg_rman_backups
drwxr-xr-x. 8 postgres postgres 4096 Nov 15 16:14 share
[postgres@node_206 /postgresql/pgsql]$vim $PGDATA/postgresql.conf
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$ls
archive_log backups bin data include lib pg_log pg_rman_backups share
[postgres@node_206 /postgresql/pgsql]$ll
total 24
drwxr-xr-x. 2 postgres postgres  6 Nov 18 00:01 archive_log
drwxrwxr-x. 2 postgres postgres  6 Nov 17 15:51 backups
drwxr-xr-x. 2 postgres postgres 4096 Nov 17 16:43 bin
drwx------. 19 postgres postgres 4096 Nov 18 00:01 data
drwxr-xr-x. 6 postgres postgres 4096 Nov 15 16:14 include
drwxr-xr-x. 4 postgres postgres 4096 Nov 17 06:37 lib
drwxr-xr-x. 2 postgres postgres 4096 Nov 18 00:01 pg_log
drwxrwxr-x. 2 postgres postgres  6 Nov 18 00:01 pg_rman_backups
drwxr-xr-x. 8 postgres postgres 4096 Nov 15 16:14 share
[postgres@node_206 /postgresql/pgsql]$ll pg_rman_backups/
total 0
[postgres@node_206 /postgresql/pgsql]$ll archive_log/
total 0
[postgres@node_206 /postgresql/pgsql]$ll
total 24
drwxr-xr-x. 2 postgres postgres  6 Nov 18 00:01 archive_log
drwxrwxr-x. 2 postgres postgres  6 Nov 17 15:51 backups
drwxr-xr-x. 2 postgres postgres 4096 Nov 17 16:43 bin
drwx------. 19 postgres postgres 4096 Nov 18 00:01 data
drwxr-xr-x. 6 postgres postgres 4096 Nov 15 16:14 include
drwxr-xr-x. 4 postgres postgres 4096 Nov 17 06:37 lib
drwxr-xr-x. 2 postgres postgres 4096 Nov 18 00:01 pg_log
drwxrwxr-x. 2 postgres postgres  6 Nov 18 00:01 pg_rman_backups
drwxr-xr-x. 8 postgres postgres 4096 Nov 15 16:14 share
[postgres@node_206 /postgresql/pgsql]$vim $PGDATA/postgresql.conf
[postgres@node_206 /postgresql/pgsql]$pg_ctl restart
waiting for server to shut down.... done
server stopped
waiting for server to start....2020-11-17 11:08:26.228 EST [59464] LOG: 00000: starting PostgreSQL 12.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
2020-11-17 11:08:26.228 EST [59464] LOCATION: PostmasterMain, postmaster.c:998
2020-11-17 11:08:26.233 EST [59464] LOG: 00000: listening on IPv4 address "0.0.0.0", port 5432
2020-11-17 11:08:26.233 EST [59464] LOCATION: StreamServerPort, pqcomm.c:593
2020-11-17 11:08:26.233 EST [59464] LOG: 00000: listening on IPv6 address "::", port 5432
2020-11-17 11:08:26.233 EST [59464] LOCATION: StreamServerPort, pqcomm.c:593
2020-11-17 11:08:26.236 EST [59464] LOG: 00000: listening on Unix socket "/tmp/.s.PGSQL.5432"
2020-11-17 11:08:26.236 EST [59464] LOCATION: StreamServerPort, pqcomm.c:587
2020-11-17 11:08:26.293 EST [59464] LOG: 00000: redirecting log output to logging collector process
2020-11-17 11:08:26.293 EST [59464] HINT: Future log output will appear in directory "/postgresql/pgsql/pg_log".
2020-11-17 11:08:26.293 EST [59464] LOCATION: SysLogger_Start, syslogger.c:675
 done
server started
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pwd
/postgresql/pgsql
[postgres@node_206 /postgresql/pgsql]$psql
psql (12.3)
Type "help" for help.
postgres=# \l
                 List of databases
  Name  | Owner  | Encoding |  Collate  |  Ctype  |  Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
 postgres | postgres | UTF8   | en_US.UTF-8 | en_US.UTF-8 |
 repmgr  | repmgr  | UTF8   | en_US.UTF-8 | en_US.UTF-8 |
 template0 | postgres | UTF8   | en_US.UTF-8 | en_US.UTF-8 | =c/postgres     +
      |     |     |       |       | postgres=CTc/postgres
 template1 | postgres | UTF8   | en_US.UTF-8 | en_US.UTF-8 | =c/postgres     +
      |     |     |       |       | postgres=CTc/postgres
(4 rows)
postgres=# \q
[postgres@node_206 /postgresql/pgsql]$pg_rman init -B /postgresql/pgsql/pg_rman_backups/
INFO: ARCLOG_PATH is set to '/postgresql/pgsql/archive_log'
INFO: SRVLOG_PATH is set to '/postgresql/pgsql/pg_log'
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$psql
psql (12.3)
Type "help" for help.
postgres=# create database test;
CREATE DATABASE
postgres=# \c test
You are now connected to database "test" as user "postgres".
test=# create table test(id int, crt_time timestamp default clock_timestamp());
CREATE TABLE
test=# insert into test (id) select n from generate_series(1,100) n;
INSERT 0 100
test=# \q
[postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -B /postgresql/pgsql/pg_rman_backups
INFO: copying database files
INFO: copying archived WAL files
INFO: backup complete
INFO: Please execute 'pg_rman validate' to verify the files are correctly copied.
[postgres@node_206 /postgresql/pgsql]$pg_rman validate -B /postgresql/pgsql/pg_rman_backups
INFO: validate: "2020-11-18 00:09:40" backup and archive log files by CRC
INFO: backup "2020-11-18 00:09:40" is valid
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$psql -d test
psql (12.3)
Type "help" for help.
test=# insert into test (id) select n from generate_series(101,110) n;
INSERT 0 10
test=# \q
[postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=incremental -B /postgresql/pgsql/pg_rman_backups
INFO: copying database files
INFO: copying archived WAL files
INFO: backup complete
INFO: Please execute 'pg_rman validate' to verify the files are correctly copied.
[postgres@node_206 /postgresql/pgsql]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/
=====================================================================
 StartTime      EndTime       Mode  Size  TLI Status
=====================================================================
2020-11-18 00:10:03 2020-11-18 00:10:05 INCR  33MB   6 DONE
2020-11-18 00:09:40 2020-11-18 00:09:42 FULL  64MB   6 OK
[postgres@node_206 /postgresql/pgsql]$pg_rman validate -B /postgresql/pgsql/pg_rman_backups
INFO: validate: "2020-11-18 00:10:03" backup and archive log files by CRC
INFO: backup "2020-11-18 00:10:03" is valid
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/
=====================================================================
 StartTime      EndTime       Mode  Size  TLI Status
=====================================================================
2020-11-18 00:10:03 2020-11-18 00:10:05 INCR  33MB   6 OK
2020-11-18 00:09:40 2020-11-18 00:09:42 FULL  64MB   6 OK
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$psql -d test
psql (12.3)
Type "help" for help.
test=# create table test2(like test);
CREATE TABLE
test=# insert into test2 (id) select n from generate_series(1,100) n;
INSERT 0 100
test=# \q
[postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -B /postgresql/pgsql/pg_rman_backups
INFO: copying database files
INFO: copying archived WAL files
INFO: backup complete
INFO: Please execute 'pg_rman validate' to verify the files are correctly copied.
[postgres@node_206 /postgresql/pgsql]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/
=====================================================================
 StartTime      EndTime       Mode  Size  TLI Status
=====================================================================
2020-11-18 00:10:49 2020-11-18 00:10:51 FULL  64MB   6 DONE
2020-11-18 00:10:03 2020-11-18 00:10:05 INCR  33MB   6 OK
2020-11-18 00:09:40 2020-11-18 00:09:42 FULL  64MB   6 OK
[postgres@node_206 /postgresql/pgsql]$pg_rman validate -B /postgresql/pgsql/pg_rman_backups
INFO: validate: "2020-11-18 00:10:49" backup and archive log files by CRC
INFO: backup "2020-11-18 00:10:49" is valid
[postgres@node_206 /postgresql/pgsql]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/
=====================================================================
 StartTime      EndTime       Mode  Size  TLI Status
=====================================================================
2020-11-18 00:10:49 2020-11-18 00:10:51 FULL  64MB   6 OK
2020-11-18 00:10:03 2020-11-18 00:10:05 INCR  33MB   6 OK
2020-11-18 00:09:40 2020-11-18 00:09:42 FULL  64MB   6 OK
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_rman delete -f 2020-11-18 00:10:03
ERROR: required parameter not specified: BACKUP_PATH (-B, --backup-path)
[postgres@node_206 /postgresql/pgsql]$pg_rman delete -f 2020-11-18 00:10:03 -B /postgresql/pgsql/pg_rman_backups/
WARNING: using force option will make some of the remaining backups unusable
DETAIL: Any remaining incremental backups that are older than the oldest available full backup cannot be restored.
INFO: delete the backup with start time: "2020-11-18 00:10:03"
INFO: delete the backup with start time: "2020-11-18 00:09:40"
[postgres@node_206 /postgresql/pgsql]$pg_rman purge -B /postgresql/pgsql/pg_rman_backups/
INFO: DELETED backup "2020-11-18 00:10:03" is purged
INFO: DELETED backup "2020-11-18 00:09:40" is purged
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/
=====================================================================
 StartTime      EndTime       Mode  Size  TLI Status
=====================================================================
2020-11-18 00:10:49 2020-11-18 00:10:51 FULL  64MB   6 OK
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$psql
psql (12.3)
Type "help" for help.
postgres=# \l
                 List of databases
  Name  | Owner  | Encoding |  Collate  |  Ctype  |  Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
 postgres | postgres | UTF8   | en_US.UTF-8 | en_US.UTF-8 |
 repmgr  | repmgr  | UTF8   | en_US.UTF-8 | en_US.UTF-8 |
 template0 | postgres | UTF8   | en_US.UTF-8 | en_US.UTF-8 | =c/postgres     +
      |     |     |       |       | postgres=CTc/postgres
 template1 | postgres | UTF8   | en_US.UTF-8 | en_US.UTF-8 | =c/postgres     +
      |     |     |       |       | postgres=CTc/postgres
 test   | postgres | UTF8   | en_US.UTF-8 | en_US.UTF-8 |
(5 rows)
postgres=# drop database test;
DROP DATABASE
postgres=# \q
[postgres@node_206 /postgresql/pgsql]$pg_ctl stop
waiting for server to shut down.... done
server stopped
[postgres@node_206 /postgresql/pgsql]$pg_rman restore -B /postgresql/pgsql/data/ --recovery-target-time='2020-11-18 00:10:49'
ERROR: required parameter not specified: ARCLOG_PATH (-A, --arclog-path)
[postgres@node_206 /postgresql/pgsql]$pg_rman restore -B /postgresql/pgsql/data/ --recovery-target-time='2020-11-18 00:10:49' -A /postgresql/pgsql/archive_log/
ERROR: required parameter not specified: SRVLOG_PATH (-S, --srvlog-path)
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_rman restore -B /postgresql/pgsql/data/ --recovery-target-time='2020-11-18 00:10:49' -A /postgresql/pgsql/archive_log/ -S /postgresql/pgsql/pg_log/
ERROR: could not open file "/postgresql/pgsql/data//pg_rman.ini": No such file or directory
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_rman restore -B /postgresql/pgsql/data/ --recovery-target-time='2020-11-18 00:10:49'
[postgres@node_206 /postgresql/pgsql]$pg_rman restore -B /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-11-18 00:10:49'
ERROR: cannot do restore
DETAIL: There is no valid full backup which can be used for given recovery condition.
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/
=====================================================================
 StartTime      EndTime       Mode  Size  TLI Status
=====================================================================
2020-11-18 00:10:49 2020-11-18 00:10:51 FULL  64MB   6 OK
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_rman restore -B /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-11-18 00:10:00\'
ERROR: cannot do restore
DETAIL: There is no valid full backup which can be used for given recovery condition.
[postgres@node_206 /postgresql/pgsql]$pg_rman restore -B /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-11-18 00:10:00'
ERROR: cannot do restore
DETAIL: There is no valid full backup which can be used for given recovery condition.
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_rman restore -B /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-11-18'
ERROR: cannot do restore
DETAIL: There is no valid full backup which can be used for given recovery condition.
[postgres@node_206 /postgresql/pgsql]$pg_rman restore -B /postgresql/pgsql/pg_rman_backups/
INFO: the recovery target timeline ID is not given
INFO: use timeline ID of current database cluster as recovery target: 6
INFO: calculating timeline branches to be used to recovery target point
INFO: searching latest full backup which can be used as restore start point
INFO: found the full backup can be used as base in recovery: "2020-11-18 00:10:49"
INFO: copying online WAL files and server log files
INFO: clearing restore destination
INFO: validate: "2020-11-18 00:10:49" backup and archive log files by SIZE
INFO: backup "2020-11-18 00:10:49" is valid
INFO: restoring database files from the full mode backup "2020-11-18 00:10:49"
INFO: searching incremental backup to be restored
INFO: searching backup which contained archived WAL files to be restored
INFO: backup "2020-11-18 00:10:49" is valid
INFO: restoring WAL files from backup "2020-11-18 00:10:49"
INFO: restoring online WAL files and server log files
INFO: add recovery related options to postgresql.conf
INFO: generating recovery.signal
INFO: restore complete
HINT: Recovery will start automatically when the PostgreSQL server is started.
[postgres@node_206 /postgresql/pgsql]$rm -f data/recovery.signal
[postgres@node_206 /postgresql/pgsql]$pg_ctl start
waiting for server to start....2020-11-17 11:14:46.684 EST [59594] LOG: 00000: starting PostgreSQL 12.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
2020-11-17 11:14:46.684 EST [59594] LOCATION: PostmasterMain, postmaster.c:998
2020-11-17 11:14:46.689 EST [59594] LOG: 00000: listening on IPv4 address "0.0.0.0", port 5432
2020-11-17 11:14:46.689 EST [59594] LOCATION: StreamServerPort, pqcomm.c:593
2020-11-17 11:14:46.689 EST [59594] LOG: 00000: listening on IPv6 address "::", port 5432
2020-11-17 11:14:46.689 EST [59594] LOCATION: StreamServerPort, pqcomm.c:593
2020-11-17 11:14:46.691 EST [59594] LOG: 00000: listening on Unix socket "/tmp/.s.PGSQL.5432"
2020-11-17 11:14:46.691 EST [59594] LOCATION: StreamServerPort, pqcomm.c:587
2020-11-17 11:14:46.732 EST [59594] LOG: 00000: redirecting log output to logging collector process
2020-11-17 11:14:46.732 EST [59594] HINT: Future log output will appear in directory "/postgresql/pgsql/pg_log".
2020-11-17 11:14:46.732 EST [59594] LOCATION: SysLogger_Start, syslogger.c:675
 stopped waiting
pg_ctl: could not start server
Examine the log output.
[postgres@node_206 /postgresql/pgsql]$touch data/recovery.signal
[postgres@node_206 /postgresql/pgsql]$pg_ctl start
waiting for server to start....2020-11-17 11:15:04.292 EST [59600] LOG: 00000: starting PostgreSQL 12.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
2020-11-17 11:15:04.292 EST [59600] LOCATION: PostmasterMain, postmaster.c:998
2020-11-17 11:15:04.293 EST [59600] LOG: 00000: listening on IPv4 address "0.0.0.0", port 5432
2020-11-17 11:15:04.293 EST [59600] LOCATION: StreamServerPort, pqcomm.c:593
2020-11-17 11:15:04.293 EST [59600] LOG: 00000: listening on IPv6 address "::", port 5432
2020-11-17 11:15:04.293 EST [59600] LOCATION: StreamServerPort, pqcomm.c:593
2020-11-17 11:15:04.296 EST [59600] LOG: 00000: listening on Unix socket "/tmp/.s.PGSQL.5432"
2020-11-17 11:15:04.296 EST [59600] LOCATION: StreamServerPort, pqcomm.c:587
2020-11-17 11:15:04.347 EST [59600] LOG: 00000: redirecting log output to logging collector process
2020-11-17 11:15:04.347 EST [59600] HINT: Future log output will appear in directory "/postgresql/pgsql/pg_log".
2020-11-17 11:15:04.347 EST [59600] LOCATION: SysLogger_Start, syslogger.c:675
 done
server started
[postgres@node_206 /postgresql/pgsql]$psql
psql (12.3)
Type "help" for help.
postgres=# \l
                 List of databases
  Name  | Owner  | Encoding |  Collate  |  Ctype  |  Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
 postgres | postgres | UTF8   | en_US.UTF-8 | en_US.UTF-8 |
 repmgr  | repmgr  | UTF8   | en_US.UTF-8 | en_US.UTF-8 |
 template0 | postgres | UTF8   | en_US.UTF-8 | en_US.UTF-8 | =c/postgres     +
      |     |     |       |       | postgres=CTc/postgres
 template1 | postgres | UTF8   | en_US.UTF-8 | en_US.UTF-8 | =c/postgres     +
      |     |     |       |       | postgres=CTc/postgres
(4 rows)
postgres=# \q
[postgres@node_206 /postgresql/pgsql]$pg_rman
ERROR: required parameter not specified: BACKUP_PATH (-B, --backup-path)
[postgres@node_206 /postgresql/pgsql]$pg_rman --help
pg_rman manage backup/recovery of PostgreSQL database.
Usage:
 pg_rman OPTION init
 pg_rman OPTION backup
 pg_rman OPTION restore
 pg_rman OPTION show [DATE]
 pg_rman OPTION show detail [DATE]
 pg_rman OPTION validate [DATE]
 pg_rman OPTION delete DATE
 pg_rman OPTION purge
Common Options:
 -D, --pgdata=PATH     location of the database storage area
 -A, --arclog-path=PATH  location of archive WAL storage area
 -S, --srvlog-path=PATH  location of server log storage area
 -B, --backup-path=PATH  location of the backup storage area
 -c, --check        show what would have been done
 -v, --verbose       show what detail messages
 -P, --progress      show progress of processed files
Backup options:
 -b, --backup-mode=MODE  full, incremental, or archive
 -s, --with-serverlog   also backup server log files
 -Z, --compress-data    compress data backup with zlib
 -C, --smooth-checkpoint  do smooth checkpoint before backup
 -F, --full-backup-on-error  switch to full backup mode
                if pg_rman cannot find validate full backup
                on current timeline
   NOTE: this option is only used in --backup-mode=incremental or archive.
 --keep-data-generations=NUM keep NUM generations of full data backup
 --keep-data-days=NUM    keep enough data backup to recover to N days ago
 --keep-arclog-files=NUM  keep NUM of archived WAL
 --keep-arclog-days=DAY  keep archived WAL modified in DAY days
 --keep-srvlog-files=NUM  keep NUM of serverlogs
 --keep-srvlog-days=DAY  keep serverlog modified in DAY days
 --standby-host=HOSTNAME  standby host when taking backup from standby
 --standby-port=PORT    standby port when taking backup from standby
Restore options:
 --recovery-target-time  time stamp up to which recovery will proceed
 --recovery-target-xid   transaction ID up to which recovery will proceed
 --recovery-target-inclusive whether we stop just after the recovery target
 --recovery-target-timeline recovering into a particular timeline
 --hard-copy         copying archivelog not symbolic link
Catalog options:
 -a, --show-all      show deleted backup too
Delete options:
 -f, --force        forcibly delete backup older than given DATE
Connection options:
 -d, --dbname=DBNAME    database to connect
 -h, --host=HOSTNAME    database server host or socket directory
 -p, --port=PORT      database server port
 -U, --username=USERNAME  user name to connect as
 -w, --no-password     never prompt for password
 -W, --password      force password prompt
Generic options:
 -q, --quiet        don't show any INFO or DEBUG messages
 --debug          show DEBUG messages
 --help          show this help, then exit
 --version         output version information, then exit
Read the website for details. <http://github.com/ossc-db/pg_rman>
Report bugs to <http://github.com/ossc-db/pg_rman/issues>.
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pwd
/postgresql/pgsql
[postgres@node_206 /postgresql/pgsql]$ls
archive_log backups bin data include lib pg_log pg_rman_backups share
[postgres@node_206 /postgresql/pgsql]$vim $PGDATA/postgresql.conf
Catalog options:
 -a, --show-all      show deleted backup too
Delete options:
 -f, --force        forcibly delete backup older than given DATE
Connection options:
 -d, --dbname=DBNAME    database to connect
 -h, --host=HOSTNAME    database server host or socket directory
 -p, --port=PORT      database server port
 -U, --username=USERNAME  user name to connect as
 -w, --no-password     never prompt for password
 -W, --password      force password prompt
Generic options:
 -q, --quiet        don't show any INFO or DEBUG messages
 --debug          show DEBUG messages
 --help          show this help, then exit
 --version         output version information, then exit
Read the website for details. <http://github.com/ossc-db/pg_rman>
Report bugs to <http://github.com/ossc-db/pg_rman/issues>.
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pwd
/postgresql/pgsql
[postgres@node_206 /postgresql/pgsql]$ls
archive_log backups bin data include lib pg_log pg_rman_backups share
[postgres@node_206 /postgresql/pgsql]$vim $PGDATA/postgresql.conf
[postgres@node_206 /postgresql/pgsql]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/
=====================================================================
 StartTime      EndTime       Mode  Size  TLI Status
=====================================================================
2020-11-18 00:10:49 2020-11-18 00:10:51 FULL  64MB   6 OK
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$ll
total 28
drwxr-xr-x. 2 postgres postgres 4096 Nov 18 00:15 archive_log
drwxrwxr-x. 2 postgres postgres  6 Nov 17 15:51 backups
drwxr-xr-x. 2 postgres postgres 4096 Nov 17 16:43 bin
drwx------. 19 postgres postgres 4096 Nov 18 02:41 data
drwxr-xr-x. 6 postgres postgres 4096 Nov 15 16:14 include
drwxr-xr-x. 4 postgres postgres 4096 Nov 17 06:37 lib
drwxr-xr-x. 2 postgres postgres 4096 Nov 18 00:15 pg_log
drwxrwxr-x. 5 postgres postgres 104 Nov 18 00:09 pg_rman_backups
drwxr-xr-x. 8 postgres postgres 4096 Nov 15 16:14 share
[postgres@node_206 /postgresql/pgsql]$vim $PGDATA/postgresql.conf
 --version         output version information, then exit
Read the website for details. <http://github.com/ossc-db/pg_rman>
Report bugs to <http://github.com/ossc-db/pg_rman/issues>.
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pwd
/postgresql/pgsql
[postgres@node_206 /postgresql/pgsql]$ls
archive_log backups bin data include lib pg_log pg_rman_backups share
[postgres@node_206 /postgresql/pgsql]$vim $PGDATA/postgresql.conf
[postgres@node_206 /postgresql/pgsql]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/
=====================================================================
 StartTime      EndTime       Mode  Size  TLI Status
=====================================================================
2020-11-18 00:10:49 2020-11-18 00:10:51 FULL  64MB   6 OK
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$ll
total 28
drwxr-xr-x. 2 postgres postgres 4096 Nov 18 00:15 archive_log
drwxrwxr-x. 2 postgres postgres  6 Nov 17 15:51 backups
drwxr-xr-x. 2 postgres postgres 4096 Nov 17 16:43 bin
drwx------. 19 postgres postgres 4096 Nov 18 02:41 data
drwxr-xr-x. 6 postgres postgres 4096 Nov 15 16:14 include
drwxr-xr-x. 4 postgres postgres 4096 Nov 17 06:37 lib
drwxr-xr-x. 2 postgres postgres 4096 Nov 18 00:15 pg_log
drwxrwxr-x. 5 postgres postgres 104 Nov 18 00:09 pg_rman_backups
drwxr-xr-x. 8 postgres postgres 4096 Nov 15 16:14 share
[postgres@node_206 /postgresql/pgsql]$vim $PGDATA/postgresql.conf
[postgres@node_206 /postgresql/pgsql]$pg_ctl restart -m fast
waiting for server to shut down.... done
server stopped
waiting for server to start....2020-11-17 13:41:36.369 EST [60239] LOG: 00000: starting PostgreSQL 12.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
2020-11-17 13:41:36.369 EST [60239] LOCATION: PostmasterMain, postmaster.c:998
2020-11-17 13:41:36.371 EST [60239] LOG: 00000: listening on IPv4 address "0.0.0.0", port 5432
2020-11-17 13:41:36.371 EST [60239] LOCATION: StreamServerPort, pqcomm.c:593
2020-11-17 13:41:36.371 EST [60239] LOG: 00000: listening on IPv6 address "::", port 5432
2020-11-17 13:41:36.371 EST [60239] LOCATION: StreamServerPort, pqcomm.c:593
2020-11-17 13:41:36.377 EST [60239] LOG: 00000: listening on Unix socket "/tmp/.s.PGSQL.5432"
2020-11-17 13:41:36.377 EST [60239] LOCATION: StreamServerPort, pqcomm.c:587
2020-11-17 13:41:36.466 EST [60239] LOG: 00000: redirecting log output to logging collector process
2020-11-17 13:41:36.466 EST [60239] HINT: Future log output will appear in directory "/postgresql/pgsql/pg_log".
2020-11-17 13:41:36.466 EST [60239] LOCATION: SysLogger_Start, syslogger.c:675
 done
server started
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$ls
archive_log backups bin data include lib pg_log pg_rman_backups share
[postgres@node_206 /postgresql/pgsql]$ll
total 28
drwxr-xr-x. 2 postgres postgres 4096 Nov 18 02:41 archive_log
drwxrwxr-x. 2 postgres postgres  6 Nov 17 15:51 backups
drwxr-xr-x. 2 postgres postgres 4096 Nov 17 16:43 bin
drwx------. 19 postgres postgres 4096 Nov 18 02:41 data
drwxr-xr-x. 6 postgres postgres 4096 Nov 15 16:14 include
drwxr-xr-x. 4 postgres postgres 4096 Nov 17 06:37 lib
drwxr-xr-x. 2 postgres postgres 4096 Nov 18 02:41 pg_log
drwxrwxr-x. 5 postgres postgres 104 Nov 18 00:09 pg_rman_backups
drwxr-xr-x. 8 postgres postgres 4096 Nov 15 16:14 share
[postgres@node_206 /postgresql/pgsql]$rm -rf archive_log/*
[postgres@node_206 /postgresql/pgsql]$rm -rf pg_rman_backups/*
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$vim $PGDATA/postgresql.conf
2020-11-17 13:41:36.369 EST [60239] LOCATION: PostmasterMain, postmaster.c:998
2020-11-17 13:41:36.371 EST [60239] LOG: 00000: listening on IPv4 address "0.0.0.0", port 5432
2020-11-17 13:41:36.371 EST [60239] LOCATION: StreamServerPort, pqcomm.c:593
2020-11-17 13:41:36.371 EST [60239] LOG: 00000: listening on IPv6 address "::", port 5432
2020-11-17 13:41:36.371 EST [60239] LOCATION: StreamServerPort, pqcomm.c:593
2020-11-17 13:41:36.377 EST [60239] LOG: 00000: listening on Unix socket "/tmp/.s.PGSQL.5432"
2020-11-17 13:41:36.377 EST [60239] LOCATION: StreamServerPort, pqcomm.c:587
2020-11-17 13:41:36.466 EST [60239] LOG: 00000: redirecting log output to logging collector process
2020-11-17 13:41:36.466 EST [60239] HINT: Future log output will appear in directory "/postgresql/pgsql/pg_log".
2020-11-17 13:41:36.466 EST [60239] LOCATION: SysLogger_Start, syslogger.c:675
 done
server started
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$ls
archive_log backups bin data include lib pg_log pg_rman_backups share
[postgres@node_206 /postgresql/pgsql]$ll
total 28
drwxr-xr-x. 2 postgres postgres 4096 Nov 18 02:41 archive_log
drwxrwxr-x. 2 postgres postgres  6 Nov 17 15:51 backups
drwxr-xr-x. 2 postgres postgres 4096 Nov 17 16:43 bin
drwx------. 19 postgres postgres 4096 Nov 18 02:41 data
drwxr-xr-x. 6 postgres postgres 4096 Nov 15 16:14 include
drwxr-xr-x. 4 postgres postgres 4096 Nov 17 06:37 lib
drwxr-xr-x. 2 postgres postgres 4096 Nov 18 02:41 pg_log
drwxrwxr-x. 5 postgres postgres 104 Nov 18 00:09 pg_rman_backups
drwxr-xr-x. 8 postgres postgres 4096 Nov 15 16:14 share
[postgres@node_206 /postgresql/pgsql]$rm -rf archive_log/*
[postgres@node_206 /postgresql/pgsql]$rm -rf pg_rman_backups/*
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$vim $PGDATA/postgresql.conf
[postgres@node_206 /postgresql/pgsql]$pg_ctl restart -m fast
waiting for server to shut down.... done
server stopped
waiting for server to start....2020-11-17 13:41:51.227 EST [60254] LOG: 00000: starting PostgreSQL 12.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
2020-11-17 13:41:51.227 EST [60254] LOCATION: PostmasterMain, postmaster.c:998
2020-11-17 13:41:51.228 EST [60254] LOG: 00000: listening on IPv4 address "0.0.0.0", port 5432
2020-11-17 13:41:51.228 EST [60254] LOCATION: StreamServerPort, pqcomm.c:593
2020-11-17 13:41:51.228 EST [60254] LOG: 00000: listening on IPv6 address "::", port 5432
2020-11-17 13:41:51.228 EST [60254] LOCATION: StreamServerPort, pqcomm.c:593
2020-11-17 13:41:51.239 EST [60254] LOG: 00000: listening on Unix socket "/tmp/.s.PGSQL.5432"
2020-11-17 13:41:51.239 EST [60254] LOCATION: StreamServerPort, pqcomm.c:587
2020-11-17 13:41:51.372 EST [60254] LOG: 00000: redirecting log output to logging collector process
2020-11-17 13:41:51.372 EST [60254] HINT: Future log output will appear in directory "/postgresql/pgsql/pg_log".
2020-11-17 13:41:51.372 EST [60254] LOCATION: SysLogger_Start, syslogger.c:675
 done
server started
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$psql
psql (12.3)
Type "help" for help.
postgres=# \l
                 List of databases
  Name  | Owner  | Encoding |  Collate  |  Ctype  |  Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
 postgres | postgres | UTF8   | en_US.UTF-8 | en_US.UTF-8 |
 repmgr  | repmgr  | UTF8   | en_US.UTF-8 | en_US.UTF-8 |
 template0 | postgres | UTF8   | en_US.UTF-8 | en_US.UTF-8 | =c/postgres     +
      |     |     |       |       | postgres=CTc/postgres
 template1 | postgres | UTF8   | en_US.UTF-8 | en_US.UTF-8 | =c/postgres     +
      |     |     |       |       | postgres=CTc/postgres
(4 rows)
postgres=# \q
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$history |grep pg_rman |grep init
 519 pg_rman init -B /postgresql/pgsql/pg_rman_backups/
 538 pg_rman init -B /postgresql/pgsql/pg_rman_backups
 544 pg_rman init -B /postgresql/pgsql/pg_rman_backups
 725 ll /postgresql/pgsql/pg_rman_backups/*init
 926 ll /postgresql/pgsql/pg_rman_backups/*init
 927 pg_rman init -B /postgresql/pgsql/pg_rman_backups
 976 pg_rman init -B
 977 pg_rman init
 980 pg_rman init
 981 pg_rman init -B /postgresql/pgsql/pg_rman_backups/
 1029 pg_rman init -B /postgresql/pgsql/pg_rman_backups/
 1102 pg_rman init -B /postgresql/pgsql/pg_rman_backups/
 1152 history |grep pg_rman |grep init
[postgres@node_206 /postgresql/pgsql]$pg_rman init -B /postgresql/pgsql/pg_rman_backups/
INFO: ARCLOG_PATH is set to '/postgresql/pgsql/archive_log'
INFO: SRVLOG_PATH is set to '/postgresql/pgsql/pg_log'
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$psql
psql (12.3)
Type "help" for help.
postgres=# create database test;
CREATE DATABASE
postgres=# \c test
You are now connected to database "test" as user "postgres".
test=# create table test(id int, crt_time timestamp default clock_timestamp());
CREATE TABLE
test=# insert into test(id) select n from generate_series
test-# (1,1000) n;
INSERT 0 1000
test=# \q
[postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -B /postgresql/pgsql/pg_rman_backups
INFO: copying database files
INFO: copying archived WAL files
INFO: backup complete
INFO: Please execute 'pg_rman validate' to verify the files are correctly copied.
[postgres@node_206 /postgresql/pgsql]$pg_rman validate -B /postgresql/pgsql/pg_rman_backups
INFO: validate: "2020-11-18 02:43:17" backup and archive log files by CRC
INFO: backup "2020-11-18 02:43:17" is valid
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/
=====================================================================
 StartTime      EndTime       Mode  Size  TLI Status
=====================================================================
2020-11-18 02:43:17 2020-11-18 02:43:19 FULL  64MB  10 OK
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$ls
archive_log backups bin data include lib pg_log pg_rman_backups share
[postgres@node_206 /postgresql/pgsql]$cd pg_rman_backups/
[postgres@node_206 /postgresql/pgsql/pg_rman_backups]$ls
20201118 backup pg_rman.ini system_identifier timeline_history
[postgres@node_206 /postgresql/pgsql/pg_rman_backups]$ll
total 8
drwx------. 3 postgres postgres 20 Nov 18 02:43 20201118
drwx------. 4 postgres postgres 34 Nov 18 02:42 backup
-rw-rw-r--. 1 postgres postgres 84 Nov 18 02:42 pg_rman.ini
-rw-rw-r--. 1 postgres postgres 40 Nov 18 02:42 system_identifier
drwx------. 2 postgres postgres 6 Nov 18 02:42 timeline_history
[postgres@node_206 /postgresql/pgsql/pg_rman_backups]$vim *ini
test=# \q
[postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -B /postgresql/pgsql/pg_rman_backups
INFO: copying database files
INFO: copying archived WAL files
INFO: backup complete
INFO: Please execute 'pg_rman validate' to verify the files are correctly copied.
[postgres@node_206 /postgresql/pgsql]$pg_rman validate -B /postgresql/pgsql/pg_rman_backups
INFO: validate: "2020-11-18 02:43:17" backup and archive log files by CRC
INFO: backup "2020-11-18 02:43:17" is valid
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/
=====================================================================
 StartTime      EndTime       Mode  Size  TLI Status
=====================================================================
2020-11-18 02:43:17 2020-11-18 02:43:19 FULL  64MB  10 OK
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$ls
archive_log backups bin data include lib pg_log pg_rman_backups share
[postgres@node_206 /postgresql/pgsql]$cd pg_rman_backups/
[postgres@node_206 /postgresql/pgsql/pg_rman_backups]$ls
20201118 backup pg_rman.ini system_identifier timeline_history
[postgres@node_206 /postgresql/pgsql/pg_rman_backups]$ll
total 8
drwx------. 3 postgres postgres 20 Nov 18 02:43 20201118
drwx------. 4 postgres postgres 34 Nov 18 02:42 backup
-rw-rw-r--. 1 postgres postgres 84 Nov 18 02:42 pg_rman.ini
-rw-rw-r--. 1 postgres postgres 40 Nov 18 02:42 system_identifier
drwx------. 2 postgres postgres 6 Nov 18 02:42 timeline_history
[postgres@node_206 /postgresql/pgsql/pg_rman_backups]$vim *ini
[postgres@node_206 /postgresql/pgsql/pg_rman_backups]$
[postgres@node_206 /postgresql/pgsql/pg_rman_backups]$
[postgres@node_206 /postgresql/pgsql/pg_rman_backups]$
[postgres@node_206 /postgresql/pgsql/pg_rman_backups]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/
=====================================================================
 StartTime      EndTime       Mode  Size  TLI Status
=====================================================================
2020-11-18 02:43:17 2020-11-18 02:43:19 FULL  64MB  10 OK
[postgres@node_206 /postgresql/pgsql/pg_rman_backups]$
[postgres@node_206 /postgresql/pgsql/pg_rman_backups]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/ detail
======================================================================================================================
 StartTime      EndTime       Mode  Data ArcLog SrvLog  Total Compressed CurTLI ParentTLI Status
======================================================================================================================
2020-11-18 02:43:17 2020-11-18 02:43:19 FULL  44MB  33MB  ----  64MB    false   10     0 OK
[postgres@node_206 /postgresql/pgsql/pg_rman_backups]$
[postgres@node_206 /postgresql/pgsql/pg_rman_backups]$
[postgres@node_206 /postgresql/pgsql/pg_rman_backups]$
[postgres@node_206 /postgresql/pgsql/pg_rman_backups]$
[postgres@node_206 /postgresql/pgsql/pg_rman_backups]$psql -U postgres -d test
psql (12.3)
Type "help" for help.
test=# \dt
    List of relations
 Schema | Name | Type | Owner 
--------+------+-------+----------
 public | test | table | postgres
(1 row)
test=# select count(*) from test;
 count
-------
 1000
(1 row)
test=# insert into test (id ) select n from generate_series(1001, 2000) n ;
INSERT 0 1000
test=# \q
[postgres@node_206 /postgresql/pgsql/pg_rman_backups]$pg_rman backup -bi -B /postgresql/pgsql/pg_rman_backups
INFO: copying database files
INFO: copying archived WAL files
INFO: backup complete
INFO: Please execute 'pg_rman validate' to verify the files are correctly copied.
INFO: start deleting old archived WAL files from ARCLOG_PATH (keep days = 10)
INFO: the threshold timestamp calculated by keep days is "2020-11-08 00:00:00"
INFO: start deleting old backup (keep generations = 3 AND keep after = 2020-09-19 00:00:00)
INFO: does not include the backup just taken
INFO: backup "2020-11-18 02:43:17" should be kept
DETAIL: This is the 1st latest full backup.
[postgres@node_206 /postgresql/pgsql/pg_rman_backups]$pg_rman validate -B /postgresql/pgsql/pg_rman_backups
INFO: validate: "2020-11-18 02:46:41" backup and archive log files by CRC
INFO: backup "2020-11-18 02:46:41" is valid
[postgres@node_206 /postgresql/pgsql/pg_rman_backups]$date
Wed Nov 18 02:48:04 CST 2020
(reverse-i-search)`': ^C
[postgres@node_206 /postgresql/pgsql/pg_rman_backups]$psql
psql (12.3)
Type "help" for help.
postgres=# select now();
       now      
-------------------------------
 2020-11-18 02:48:18.215429+08
(1 row)
postgres=# \q
[postgres@node_206 /postgresql/pgsql/pg_rman_backups]$exit
logout
[root@node_206 ~]# history | grep ntpdate
 467 history | grep ntpdate
[root@node_206 ~]# ntpdate time.ntp.org
Error resolving time.ntp.org: Name or service not known (-2)
18 Nov 02:49:19 ntpdate[60350]: Can't find host time.ntp.org: Name or service not known (-2)
18 Nov 02:49:19 ntpdate[60350]: no servers can be used, exiting
[root@node_206 ~]# ping baidu.com
PING baidu.com (220.181.38.148) 56(84) bytes of data.
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=1 ttl=50 time=61.3 ms
^C
--- baidu.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 61.374/61.374/61.374/0.000 ms
[root@node_206 ~]# ntpdate 0.cn.pool.ntp.org
20 Dec 22:36:38 ntpdate[60355]: step time server 5.79.108.34 offset 2836002.583561 sec
[root@node_206 ~]#
[root@node_206 ~]# date
Sun Dec 20 22:36:40 CST 2020
[root@node_206 ~]# vim /etc/crontab
postgres=# select now();
       now      
-------------------------------
 2020-11-18 02:48:18.215429+08
(1 row)
postgres=# \q
[postgres@node_206 /postgresql/pgsql/pg_rman_backups]$exit
logout
[root@node_206 ~]# history | grep ntpdate
 467 history | grep ntpdate
[root@node_206 ~]# ntpdate time.ntp.org
Error resolving time.ntp.org: Name or service not known (-2)
18 Nov 02:49:19 ntpdate[60350]: Can't find host time.ntp.org: Name or service not known (-2)
18 Nov 02:49:19 ntpdate[60350]: no servers can be used, exiting
[root@node_206 ~]# ping baidu.com
PING baidu.com (220.181.38.148) 56(84) bytes of data.
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=1 ttl=50 time=61.3 ms
^C
--- baidu.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 61.374/61.374/61.374/0.000 ms
[root@node_206 ~]# ntpdate 0.cn.pool.ntp.org
20 Dec 22:36:38 ntpdate[60355]: step time server 5.79.108.34 offset 2836002.583561 sec
[root@node_206 ~]#
[root@node_206 ~]# date
Sun Dec 20 22:36:40 CST 2020
[root@node_206 ~]# vim /etc/crontab
[root@node_206 ~]# lsd
-bash: lsd: command not found
[root@node_206 ~]#
[root@node_206 ~]# ls
anaconda-ks.cfg
[root@node_206 ~]# date
Sun Dec 20 22:37:13 CST 2020
[root@node_206 ~]# psql
-bash: psql: command not found
[root@node_206 ~]# ip ro show
default via 192.168.0.1 dev eth0 proto static metric 100
192.168.0.0/24 dev eth0 proto kernel scope link src 192.168.0.206 metric 100
[root@node_206 ~]# psql
-bash: psql: command not found
[root@node_206 ~]# su - postgres
Last login: Tue Nov 17 22:47:52 CST 2020 on pts/1
[postgres@node_206 ~]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/
=====================================================================
 StartTime      EndTime       Mode  Size  TLI Status
=====================================================================
2020-11-18 02:46:41 2020-11-18 02:46:43 INCR  59kB  10 OK
2020-11-18 02:43:17 2020-11-18 02:43:19 FULL  64MB  10 OK
[postgres@node_206 ~]$
[postgres@node_206 ~]$vim $PGDATA/postgresql.conf
[root@node_206 ~]# ntpdate 0.cn.pool.ntp.org
20 Dec 22:36:38 ntpdate[60355]: step time server 5.79.108.34 offset 2836002.583561 sec
[root@node_206 ~]#
[root@node_206 ~]# date
Sun Dec 20 22:36:40 CST 2020
[root@node_206 ~]# vim /etc/crontab
[root@node_206 ~]# lsd
-bash: lsd: command not found
[root@node_206 ~]#
[root@node_206 ~]# ls
anaconda-ks.cfg
[root@node_206 ~]# date
Sun Dec 20 22:37:13 CST 2020
[root@node_206 ~]# psql
-bash: psql: command not found
[root@node_206 ~]# ip ro show
default via 192.168.0.1 dev eth0 proto static metric 100
192.168.0.0/24 dev eth0 proto kernel scope link src 192.168.0.206 metric 100
[root@node_206 ~]# psql
-bash: psql: command not found
[root@node_206 ~]# su - postgres
Last login: Tue Nov 17 22:47:52 CST 2020 on pts/1
[postgres@node_206 ~]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/
=====================================================================
 StartTime      EndTime       Mode  Size  TLI Status
=====================================================================
2020-11-18 02:46:41 2020-11-18 02:46:43 INCR  59kB  10 OK
2020-11-18 02:43:17 2020-11-18 02:43:19 FULL  64MB  10 OK
[postgres@node_206 ~]$
[postgres@node_206 ~]$vim $PGDATA/postgresql.conf
[postgres@node_206 ~]$pg_ctl restart -m fast
waiting for server to shut down....
 done
server stopped
waiting for server to start....2020-12-20 09:37:46.967 EST [60411] LOG: 00000: starting PostgreSQL 12.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
2020-12-20 09:37:46.967 EST [60411] LOCATION: PostmasterMain, postmaster.c:998
2020-12-20 09:37:46.969 EST [60411] LOG: 00000: listening on IPv4 address "0.0.0.0", port 5432
2020-12-20 09:37:46.969 EST [60411] LOCATION: StreamServerPort, pqcomm.c:593
2020-12-20 09:37:46.969 EST [60411] LOG: 00000: listening on IPv6 address "::", port 5432
2020-12-20 09:37:46.969 EST [60411] LOCATION: StreamServerPort, pqcomm.c:593
2020-12-20 09:37:46.971 EST [60411] LOG: 00000: listening on Unix socket "/tmp/.s.PGSQL.5432"
2020-12-20 09:37:46.971 EST [60411] LOCATION: StreamServerPort, pqcomm.c:587
2020-12-20 09:37:47.014 EST [60411] LOG: 00000: redirecting log output to logging collector process
2020-12-20 09:37:47.014 EST [60411] HINT: Future log output will appear in directory "/postgresql/pgsql/pg_log".
2020-12-20 09:37:47.014 EST [60411] LOCATION: SysLogger_Start, syslogger.c:675
 done
server started
[postgres@node_206 ~]$
[postgres@node_206 ~]$ls
postgres_dba test.dmp
[postgres@node_206 ~]$ll
total 4
drwxrwxr-x. 10 postgres postgres 198 Nov 17 03:00 postgres_dba
-rw-rw-r--. 1 postgres postgres 1275 Nov 17 14:08 test.dmp
[postgres@node_206 ~]$cd /postgresql/p
-bash: cd: /postgresql/p: No such file or directory
[postgres@node_206 ~]$cd /postgresql/pgsql/
[postgres@node_206 /postgresql/pgsql]$ls
archive_log backups bin data include lib pg_log pg_rman_backups share
[postgres@node_206 /postgresql/pgsql]$ll
total 28
drwxr-xr-x. 2 postgres postgres 262 Dec 20 22:37 archive_log
drwxrwxr-x. 2 postgres postgres  6 Nov 17 15:51 backups
drwxr-xr-x. 2 postgres postgres 4096 Nov 17 16:43 bin
drwx------. 19 postgres postgres 4096 Dec 20 22:37 data
drwxr-xr-x. 6 postgres postgres 4096 Nov 15 16:14 include
drwxr-xr-x. 4 postgres postgres 4096 Nov 17 06:37 lib
drwxr-xr-x. 2 postgres postgres 4096 Dec 20 22:37 pg_log
drwxrwxr-x. 5 postgres postgres 104 Nov 18 02:45 pg_rman_backups
drwxr-xr-x. 8 postgres postgres 4096 Nov 15 16:14 share
[postgres@node_206 /postgresql/pgsql]$rm -rf archive_log/* pg_rman_backups/*
[postgres@node_206 /postgresql/pgsql]$ll
total 28
drwxr-xr-x. 2 postgres postgres  6 Dec 20 22:37 archive_log
drwxrwxr-x. 2 postgres postgres  6 Nov 17 15:51 backups
drwxr-xr-x. 2 postgres postgres 4096 Nov 17 16:43 bin
drwx------. 19 postgres postgres 4096 Dec 20 22:37 data
drwxr-xr-x. 6 postgres postgres 4096 Nov 15 16:14 include
drwxr-xr-x. 4 postgres postgres 4096 Nov 17 06:37 lib
drwxr-xr-x. 2 postgres postgres 4096 Dec 20 22:37 pg_log
drwxrwxr-x. 2 postgres postgres  6 Dec 20 22:37 pg_rman_backups
drwxr-xr-x. 8 postgres postgres 4096 Nov 15 16:14 share
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$ll backups/
total 0
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$vim $PGDATA/postgresql.conf
[postgres@node_206 /postgresql/pgsql]$ls
archive_log backups bin data include lib pg_log pg_rman_backups share
[postgres@node_206 /postgresql/pgsql]$ll
total 28
drwxr-xr-x. 2 postgres postgres 262 Dec 20 22:37 archive_log
drwxrwxr-x. 2 postgres postgres  6 Nov 17 15:51 backups
drwxr-xr-x. 2 postgres postgres 4096 Nov 17 16:43 bin
drwx------. 19 postgres postgres 4096 Dec 20 22:37 data
drwxr-xr-x. 6 postgres postgres 4096 Nov 15 16:14 include
drwxr-xr-x. 4 postgres postgres 4096 Nov 17 06:37 lib
drwxr-xr-x. 2 postgres postgres 4096 Dec 20 22:37 pg_log
drwxrwxr-x. 5 postgres postgres 104 Nov 18 02:45 pg_rman_backups
drwxr-xr-x. 8 postgres postgres 4096 Nov 15 16:14 share
[postgres@node_206 /postgresql/pgsql]$rm -rf archive_log/* pg_rman_backups/*
[postgres@node_206 /postgresql/pgsql]$ll
total 28
drwxr-xr-x. 2 postgres postgres  6 Dec 20 22:37 archive_log
drwxrwxr-x. 2 postgres postgres  6 Nov 17 15:51 backups
drwxr-xr-x. 2 postgres postgres 4096 Nov 17 16:43 bin
drwx------. 19 postgres postgres 4096 Dec 20 22:37 data
drwxr-xr-x. 6 postgres postgres 4096 Nov 15 16:14 include
drwxr-xr-x. 4 postgres postgres 4096 Nov 17 06:37 lib
drwxr-xr-x. 2 postgres postgres 4096 Dec 20 22:37 pg_log
drwxrwxr-x. 2 postgres postgres  6 Dec 20 22:37 pg_rman_backups
drwxr-xr-x. 8 postgres postgres 4096 Nov 15 16:14 share
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$ll backups/
total 0
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$vim $PGDATA/postgresql.conf
[postgres@node_206 /postgresql/pgsql]$pg_ctl restart -m fast
waiting for server to shut down.... done
server stopped
waiting for server to start....2020-12-20 09:38:08.353 EST [60437] LOG: 00000: starting PostgreSQL 12.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
2020-12-20 09:38:08.353 EST [60437] LOCATION: PostmasterMain, postmaster.c:998
2020-12-20 09:38:08.358 EST [60437] LOG: 00000: listening on IPv4 address "0.0.0.0", port 5432
2020-12-20 09:38:08.358 EST [60437] LOCATION: StreamServerPort, pqcomm.c:593
2020-12-20 09:38:08.358 EST [60437] LOG: 00000: listening on IPv6 address "::", port 5432
2020-12-20 09:38:08.358 EST [60437] LOCATION: StreamServerPort, pqcomm.c:593
2020-12-20 09:38:08.364 EST [60437] LOG: 00000: listening on Unix socket "/tmp/.s.PGSQL.5432"
2020-12-20 09:38:08.364 EST [60437] LOCATION: StreamServerPort, pqcomm.c:587
2020-12-20 09:38:08.419 EST [60437] LOG: 00000: redirecting log output to logging collector process
2020-12-20 09:38:08.419 EST [60437] HINT: Future log output will appear in directory "/postgresql/pgsql/pg_log".
2020-12-20 09:38:08.419 EST [60437] LOCATION: SysLogger_Start, syslogger.c:675
 done
server started
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$ls
archive_log backups bin data include lib pg_log pg_rman_backups share
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_rman init -B /postgresql/pgsql/pg_rman_backups/
INFO: ARCLOG_PATH is set to '/postgresql/pgsql/archive_log'
INFO: SRVLOG_PATH is set to '/postgresql/pgsql/pg_log'
[postgres@node_206 /postgresql/pgsql]$vim pg_rman_backups/pg_rman.ini
[postgres@node_206 /postgresql/pgsql]$ll backups/
total 0
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$vim $PGDATA/postgresql.conf
[postgres@node_206 /postgresql/pgsql]$pg_ctl restart -m fast
waiting for server to shut down.... done
server stopped
waiting for server to start....2020-12-20 09:38:08.353 EST [60437] LOG: 00000: starting PostgreSQL 12.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
2020-12-20 09:38:08.353 EST [60437] LOCATION: PostmasterMain, postmaster.c:998
2020-12-20 09:38:08.358 EST [60437] LOG: 00000: listening on IPv4 address "0.0.0.0", port 5432
2020-12-20 09:38:08.358 EST [60437] LOCATION: StreamServerPort, pqcomm.c:593
2020-12-20 09:38:08.358 EST [60437] LOG: 00000: listening on IPv6 address "::", port 5432
2020-12-20 09:38:08.358 EST [60437] LOCATION: StreamServerPort, pqcomm.c:593
2020-12-20 09:38:08.364 EST [60437] LOG: 00000: listening on Unix socket "/tmp/.s.PGSQL.5432"
2020-12-20 09:38:08.364 EST [60437] LOCATION: StreamServerPort, pqcomm.c:587
2020-12-20 09:38:08.419 EST [60437] LOG: 00000: redirecting log output to logging collector process
2020-12-20 09:38:08.419 EST [60437] HINT: Future log output will appear in directory "/postgresql/pgsql/pg_log".
2020-12-20 09:38:08.419 EST [60437] LOCATION: SysLogger_Start, syslogger.c:675
 done
server started
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$ls
archive_log backups bin data include lib pg_log pg_rman_backups share
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_rman init -B /postgresql/pgsql/pg_rman_backups/
INFO: ARCLOG_PATH is set to '/postgresql/pgsql/archive_log'
INFO: SRVLOG_PATH is set to '/postgresql/pgsql/pg_log'
[postgres@node_206 /postgresql/pgsql]$vim pg_rman_backups/pg_rman.ini
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/
=====================================================================
 StartTime      EndTime       Mode  Size  TLI Status
=====================================================================
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$psql -Upostgres
psql (12.3)
Type "help" for help.
postgres=# \l
                 List of databases
  Name  | Owner  | Encoding |  Collate  |  Ctype  |  Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
 postgres | postgres | UTF8   | en_US.UTF-8 | en_US.UTF-8 |
 repmgr  | repmgr  | UTF8   | en_US.UTF-8 | en_US.UTF-8 |
 template0 | postgres | UTF8   | en_US.UTF-8 | en_US.UTF-8 | =c/postgres     +
      |     |     |       |       | postgres=CTc/postgres
 template1 | postgres | UTF8   | en_US.UTF-8 | en_US.UTF-8 | =c/postgres     +
      |     |     |       |       | postgres=CTc/postgres
 test   | postgres | UTF8   | en_US.UTF-8 | en_US.UTF-8 |
(5 rows)
postgres=# \c test
You are now connected to database "test" as user "postgres".
test=# create table test_pg_rman (id int, crt_time timestamp default clock_timestamp());
CREATE TABLE
test=# insert into test_pg_rman (id) select n from generate_series(1,10000) n;
INSERT 0 10000
test=# \q
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -B /postgresql/pgsql/pg_rman_backups
INFO: copying database files
INFO: copying archived WAL files
INFO: backup complete
INFO: Please execute 'pg_rman validate' to verify the files are correctly copied.
INFO: start deleting old archived WAL files from ARCLOG_PATH (keep days = 10)
INFO: the threshold timestamp calculated by keep days is "2020-12-10 00:00:00"
INFO: start deleting old backup (keep generations = 3 AND keep after = 2020-10-21 00:00:00)
INFO: does not include the backup just taken
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_rman validate -B /postgresql/pgsql/pg_rman_backups
INFO: validate: "2020-12-20 22:39:35" backup and archive log files by CRC
INFO: backup "2020-12-20 22:39:35" is valid
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$cat pg_rman_backups/*ini
ARCLOG_PATH='/postgresql/pgsql/archive_log'
SRVLOG_PATH='/postgresql/pgsql/pg_log'
COMPRESS_DATA = YES
KEEP_ARCLOG_DAYS = 10
KEEP_DATA_GENERATIONS = 3
KEEP_DATA_DAYS = 60
KEEP_SRVLOG_DAYS = 10
[postgres@node_206 /postgresql/pgsql]$ll /postgresql/pgsql/pg_log/
total 288
-rw-------. 1 postgres postgres 256 Nov 15 17:39 postgresql-2020-11-15_043957.log
-rw-------. 1 postgres postgres 256 Nov 15 18:00 postgresql-2020-11-15_050047.log
-rw-------. 1 postgres postgres 256 Nov 15 18:08 postgresql-2020-11-15_050800.log
-rw-------. 1 postgres postgres  0 Nov 16 13:00 postgresql-2020-11-16_000000.log
-rw-------. 1 postgres postgres 256 Nov 17 07:32 postgresql-2020-11-16_183244.log
-rw-------. 1 postgres postgres 256 Nov 17 07:33 postgresql-2020-11-16_183333.log
-rw-------. 1 postgres postgres 256 Nov 17 09:22 postgresql-2020-11-16_202244.log
-rw-------. 1 postgres postgres 256 Nov 17 09:26 postgresql-2020-11-16_202616.log
-rw-------. 1 postgres postgres 256 Nov 17 09:32 postgresql-2020-11-16_203210.log
-rw-------. 1 postgres postgres  0 Nov 17 13:00 postgresql-2020-11-17_000000.log
-rw-------. 1 postgres postgres 256 Nov 17 16:49 postgresql-2020-11-17_034947.log
-rw-------. 1 postgres postgres 448 Nov 17 17:06 postgresql-2020-11-17_040642.log
-rw-------. 1 postgres postgres 448 Nov 17 17:08 postgresql-2020-11-17_040822.log
-rw-------. 1 postgres postgres 256 Nov 17 17:09 postgresql-2020-11-17_040929.log
-rw-------. 1 postgres postgres 256 Nov 17 17:11 postgresql-2020-11-17_041114.log
-rw-------. 1 postgres postgres 448 Nov 17 17:11 postgresql-2020-11-17_041147.log
-rw-------. 1 postgres postgres 448 Nov 17 17:13 postgresql-2020-11-17_041342.log
-rw-------. 1 postgres postgres 256 Nov 17 17:15 postgresql-2020-11-17_041506.log
-rw-------. 1 postgres postgres 448 Nov 17 17:18 postgresql-2020-11-17_041841.log
-rw-------. 1 postgres postgres 256 Nov 17 17:20 postgresql-2020-11-17_042040.log
-rw-------. 1 postgres postgres 744 Nov 17 17:23 postgresql-2020-11-17_042334.log
-rw-------. 1 postgres postgres 448 Nov 17 17:31 postgresql-2020-11-17_043101.log
-rw-------. 1 postgres postgres 352 Nov 17 17:46 postgresql-2020-11-17_044648.log
-rw-------. 1 postgres postgres 352 Nov 17 17:47 postgresql-2020-11-17_044749.log
-rw-------. 1 postgres postgres 256 Nov 17 17:48 postgresql-2020-11-17_044854.log
-rw-------. 1 postgres postgres 256 Nov 17 18:10 postgresql-2020-11-17_051036.log
-rw-------. 1 postgres postgres 256 Nov 17 18:12 postgresql-2020-11-17_051236.log
-rw-------. 1 postgres postgres 256 Nov 17 18:29 postgresql-2020-11-17_052955.log
-rw-------. 1 postgres postgres 1384 Nov 17 18:32 postgresql-2020-11-17_053216.log
-rw-------. 1 postgres postgres 256 Nov 17 23:25 postgresql-2020-11-17_102510.log
-rw-------. 1 postgres postgres 256 Nov 17 23:27 postgresql-2020-11-17_102736.log
-rw-------. 1 postgres postgres 256 Nov 17 23:32 postgresql-2020-11-17_103209.log
-rw-------. 1 postgres postgres 256 Nov 17 23:34 postgresql-2020-11-17_103402.log
-rw-------. 1 postgres postgres 256 Nov 17 23:34 postgresql-2020-11-17_103422.log
-rw-------. 1 postgres postgres 256 Nov 17 23:36 postgresql-2020-11-17_103641.log
-rw-------. 1 postgres postgres 256 Nov 17 23:45 postgresql-2020-11-17_104513.log
-rw-------. 1 postgres postgres 256 Nov 17 23:53 postgresql-2020-11-17_105341.log
-rw-------. 1 postgres postgres 448 Nov 18 00:00 postgresql-2020-11-17_110030.log
-rw-------. 1 postgres postgres 256 Nov 18 00:00 postgresql-2020-11-17_110051.log
-rw-------. 1 postgres postgres 256 Nov 18 00:01 postgresql-2020-11-17_110130.log
-rw-------. 1 postgres postgres 256 Nov 18 00:08 postgresql-2020-11-17_110826.log
-rw-------. 1 postgres postgres 256 Nov 18 00:14 postgresql-2020-11-17_111446.log
-rw-------. 1 postgres postgres 1136 Nov 18 00:15 postgresql-2020-11-17_111504.log
-rw-------. 1 postgres postgres 256 Nov 18 02:41 postgresql-2020-11-17_134136.log
-rw-------. 1 postgres postgres 256 Nov 18 02:41 postgresql-2020-11-17_134151.log
-rw-------. 1 postgres postgres 256 Nov 17 17:28 postgresql-2020-11-17_172801.log
-rw-------. 1 postgres postgres 256 Nov 17 17:40 postgresql-2020-11-17_174037.log
-rw-------. 1 postgres postgres 256 Nov 17 17:44 postgresql-2020-11-17_174409.log
-rw-------. 1 postgres postgres 560 Nov 17 17:50 postgresql-2020-11-17_175020.log
-rw-------. 1 postgres postgres 560 Nov 17 17:52 postgresql-2020-11-17_175256.log
-rw-------. 1 postgres postgres 360 Nov 17 17:58 postgresql-2020-11-17_175847.log
-rw-------. 1 postgres postgres 256 Nov 17 17:59 postgresql-2020-11-17_175928.log
-rw-------. 1 postgres postgres 360 Nov 17 18:00 postgresql-2020-11-17_180030.log
-rw-------. 1 postgres postgres 360 Nov 17 18:01 postgresql-2020-11-17_180115.log
-rw-------. 1 postgres postgres 256 Nov 17 18:04 postgresql-2020-11-17_180404.log
-rw-------. 1 postgres postgres 360 Nov 17 18:07 postgresql-2020-11-17_180712.log
-rw-------. 1 postgres postgres 360 Nov 17 18:07 postgresql-2020-11-17_180740.log
-rw-------. 1 postgres postgres 360 Nov 17 18:11 postgresql-2020-11-17_181126.log
-rw-------. 1 postgres postgres 360 Nov 17 18:19 postgresql-2020-11-17_181918.log
-rw-------. 1 postgres postgres 256 Nov 17 18:24 postgresql-2020-11-17_182446.log
-rw-------. 1 postgres postgres 256 Nov 17 18:25 postgresql-2020-11-17_182540.log
-rw-------. 1 postgres postgres 256 Nov 17 18:26 postgresql-2020-11-17_182619.log
-rw-------. 1 postgres postgres 256 Nov 17 18:27 postgresql-2020-11-17_182733.log
-rw-------. 1 postgres postgres 256 Nov 17 18:27 postgresql-2020-11-17_182743.log
-rw-------. 1 postgres postgres 256 Nov 17 18:28 postgresql-2020-11-17_182847.log
-rw-------. 1 postgres postgres 256 Nov 17 18:29 postgresql-2020-11-17_182916.log
-rw-------. 1 postgres postgres 256 Nov 17 18:30 postgresql-2020-11-17_183028.log
-rw-------. 1 postgres postgres 256 Nov 17 18:33 postgresql-2020-11-17_183304.log
-rw-------. 1 postgres postgres 256 Nov 17 18:34 postgresql-2020-11-17_183413.log
-rw-------. 1 postgres postgres 256 Nov 17 18:34 postgresql-2020-11-17_183450.log
-rw-------. 1 postgres postgres 256 Nov 17 23:06 postgresql-2020-11-17_230648.log
-rw-------. 1 postgres postgres 256 Nov 17 23:20 postgresql-2020-11-17_232015.log
-rw-------. 1 postgres postgres 256 Dec 20 22:37 postgresql-2020-12-20_093747.log
-rw-------. 1 postgres postgres 256 Dec 20 22:38 postgresql-2020-12-20_093808.log
[postgres@node_206 /postgresql/pgsql]$cat pg_rman_backups/*ini
ARCLOG_PATH='/postgresql/pgsql/archive_log'
SRVLOG_PATH='/postgresql/pgsql/pg_log'
COMPRESS_DATA = YES
KEEP_ARCLOG_DAYS = 10
KEEP_DATA_GENERATIONS = 3
KEEP_DATA_DAYS = 60
KEEP_SRVLOG_DAYS = 10
[postgres@node_206 /postgresql/pgsql]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/
=====================================================================
 StartTime      EndTime       Mode  Size  TLI Status
=====================================================================
2020-12-20 22:39:35 2020-12-20 22:39:37 FULL 5451kB  10 OK
[postgres@node_206 /postgresql/pgsql]$psql -d test
psql (12.3)
Type "help" for help.
test=# select count(*) from test_pg_rman ;
 count
-------
 10000
(1 row)
test=# insert into test_pg_rman (id) select n from generate_series(10001,20000) n;
INSERT 0 10000
test=# \q
[postgres@node_206 /postgresql/pgsql]$pg_rman backup -bi -B /postgresql/pgsql/pg_rman_backups
INFO: copying database files
INFO: copying archived WAL files
INFO: backup complete
INFO: Please execute 'pg_rman validate' to verify the files are correctly copied.
INFO: start deleting old archived WAL files from ARCLOG_PATH (keep days = 10)
INFO: the threshold timestamp calculated by keep days is "2020-12-10 00:00:00"
INFO: start deleting old backup (keep generations = 3 AND keep after = 2020-10-21 00:00:00)
INFO: does not include the backup just taken
INFO: backup "2020-12-20 22:39:35" should be kept
DETAIL: This is the 1st latest full backup.
[postgres@node_206 /postgresql/pgsql]$pg_rman validate -B /postgresql/pgsql/pg_rman_backups
INFO: validate: "2020-12-20 22:41:40" backup and archive log files by CRC
INFO: backup "2020-12-20 22:41:40" is valid
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/
=====================================================================
 StartTime      EndTime       Mode  Size  TLI Status
=====================================================================
2020-12-20 22:41:40 2020-12-20 22:41:43 INCR  390kB  10 OK
2020-12-20 22:39:35 2020-12-20 22:39:37 FULL 5451kB  10 OK
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$psql -U test
psql: error: could not connect to server: FATAL: role "test" does not exist
[postgres@node_206 /postgresql/pgsql]$psql -U postgres -d test
psql (12.3)
Type "help" for help.
test=# truncate test_pg_rman ;
TRUNCATE TABLE
test=# \q
[postgres@node_206 /postgresql/pgsql]$pg_ctl stop
waiting for server to shut down.... done
server stopped
[postgres@node_206 /postgresql/pgsql]$pg_rman restore -B /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-12-20 22:39:35'
ERROR: cannot do restore
DETAIL: There is no valid full backup which can be used for given recovery condition.
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_rman restore -B /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-12-20 22:41:40'
INFO: the recovery target timeline ID is not given
INFO: use timeline ID of current database cluster as recovery target: 10
INFO: calculating timeline branches to be used to recovery target point
INFO: searching latest full backup which can be used as restore start point
INFO: found the full backup can be used as base in recovery: "2020-12-20 22:39:35"
INFO: copying online WAL files and server log files
INFO: clearing restore destination
INFO: validate: "2020-12-20 22:39:35" backup and archive log files by SIZE
INFO: backup "2020-12-20 22:39:35" is valid
INFO: restoring database files from the full mode backup "2020-12-20 22:39:35"
INFO: searching incremental backup to be restored
INFO: searching backup which contained archived WAL files to be restored
INFO: backup "2020-12-20 22:39:35" is valid
INFO: restoring WAL files from backup "2020-12-20 22:39:35"
INFO: backup "2020-12-20 22:41:40" is valid
INFO: restoring WAL files from backup "2020-12-20 22:41:40"
INFO: restoring online WAL files and server log files
INFO: add recovery related options to postgresql.conf
INFO: generating recovery.signal
INFO: restore complete
HINT: Recovery will start automatically when the PostgreSQL server is started.
[postgres@node_206 /postgresql/pgsql]$pg_ctl start
waiting for server to start....2020-12-20 09:43:32.516 EST [60584] LOG: 00000: starting PostgreSQL 12.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
2020-12-20 09:43:32.516 EST [60584] LOCATION: PostmasterMain, postmaster.c:998
2020-12-20 09:43:32.518 EST [60584] LOG: 00000: listening on IPv4 address "0.0.0.0", port 5432
2020-12-20 09:43:32.518 EST [60584] LOCATION: StreamServerPort, pqcomm.c:593
2020-12-20 09:43:32.519 EST [60584] LOG: 00000: listening on IPv6 address "::", port 5432
2020-12-20 09:43:32.519 EST [60584] LOCATION: StreamServerPort, pqcomm.c:593
2020-12-20 09:43:32.520 EST [60584] LOG: 00000: listening on Unix socket "/tmp/.s.PGSQL.5432"
2020-12-20 09:43:32.520 EST [60584] LOCATION: StreamServerPort, pqcomm.c:587
2020-12-20 09:43:32.565 EST [60584] LOG: 00000: redirecting log output to logging collector process
2020-12-20 09:43:32.565 EST [60584] HINT: Future log output will appear in directory "/postgresql/pgsql/pg_log".
2020-12-20 09:43:32.565 EST [60584] LOCATION: SysLogger_Start, syslogger.c:675
 done
server started
[postgres@node_206 /postgresql/pgsql]$psql
psql (12.3)
Type "help" for help.
postgres=# select * from pg_is_in_recovery();
 pg_is_in_recovery
-------------------
 t
(1 row)
postgres=# select pg_wal_replay_resume();
 pg_wal_replay_resume
----------------------
 
(1 row)
postgres=# select * from pg_is_in_recovery();
 pg_is_in_recovery
-------------------
 f
(1 row)
postgres=# \q
[postgres@node_206 /postgresql/pgsql]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/
=====================================================================
 StartTime      EndTime       Mode  Size  TLI Status
=====================================================================
2020-12-20 22:41:40 2020-12-20 22:41:43 INCR  390kB  10 OK
2020-12-20 22:39:35 2020-12-20 22:39:37 FULL 5451kB  10 OK
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_controldata /postgresql/pgsql/data/
pg_control version number:      1201
Catalog version number:        201909212
Database system identifier:      6895281636782426835
Database cluster state:        in production
pg_control last modified:       Sun 20 Dec 2020 10:43:51 PM CST
Latest checkpoint location:      0/86000028
Latest checkpoint's REDO location:  0/86000028
Latest checkpoint's REDO WAL file:  0000000B0000000000000086
Latest checkpoint's TimeLineID:    11
Latest checkpoint's PrevTimeLineID:  10
Latest checkpoint's full_page_writes: on
Latest checkpoint's NextXID:     0:7753
Latest checkpoint's NextOID:     25080
Latest checkpoint's NextMultiXactId: 1
Latest checkpoint's NextMultiOffset: 0
Latest checkpoint's oldestXID:    479
Latest checkpoint's oldestXID's DB:  1
Latest checkpoint's oldestActiveXID: 0
Latest checkpoint's oldestMultiXid:  1
Latest checkpoint's oldestMulti's DB: 1
Latest checkpoint's oldestCommitTsXid:0
Latest checkpoint's newestCommitTsXid:0
Time of latest checkpoint:      Sun 20 Dec 2020 10:43:51 PM CST
Fake LSN counter for unlogged rels:  0/3E8
Minimum recovery ending location:   0/0
Min recovery ending loc's timeline:  0
Backup start location:        0/0
Backup end location:         0/0
End-of-backup record required:    no
wal_level setting:          replica
wal_log_hints setting:        on
max_connections setting:       200
max_worker_processes setting:     8
max_wal_senders setting:       10
max_prepared_xacts setting:      0
max_locks_per_xact setting:      64
track_commit_timestamp setting:    off
Maximum data alignment:        8
Database block size:         8192
Blocks per segment of large relation: 131072
WAL block size:            8192
Bytes per WAL segment:        16777216
Maximum length of identifiers:    64
Maximum columns in an index:     32
Maximum size of a TOAST chunk:    1996
Size of a large-object chunk:     2048
Date/time type storage:        64-bit integers
Float4 argument passing:       by value
Float8 argument passing:       by value
Data page checksum version:      0
Mock authentication nonce:      0e803fe626d0bf49403235ba1f4f8a665eb48d4d847cb7863dcad401e65676ca
[postgres@node_206 /postgresql/pgsql]$ll data/pg_wal/
total 180268
-rw-------. 1 postgres postgres    42 Dec 20 22:43 00000002.history
-rw-------. 1 postgres postgres    85 Dec 20 22:43 00000003.history
-rw-------. 1 postgres postgres   128 Dec 20 22:43 00000004.history
-rw-------. 1 postgres postgres   171 Dec 20 22:43 00000005.history
-rw-------. 1 postgres postgres   216 Dec 20 22:43 00000006.history
-rw-------. 1 postgres postgres   261 Dec 20 22:43 00000007.history
-rw-------. 1 postgres postgres   261 Dec 20 22:43 00000008.history
-rw-------. 1 postgres postgres   304 Dec 20 22:43 00000009.history
-rw-------. 1 postgres postgres   349 Dec 20 22:43 0000000A0000000000000085.00000028.backup
-rw-------. 1 postgres postgres   259 Dec 20 22:43 0000000A.history
-rw-------. 1 postgres postgres 16777216 Dec 20 22:43 0000000B0000000000000086
-rw-------. 1 postgres postgres 16777216 Dec 20 22:43 0000000B0000000000000087
-rw-------. 1 postgres postgres 16777216 Dec 20 22:43 0000000B0000000000000088
-rw-------. 1 postgres postgres 16777216 Dec 20 22:43 0000000B0000000000000089
-rw-------. 1 postgres postgres 16777216 Dec 20 22:43 0000000B000000000000008A
-rw-------. 1 postgres postgres 16777216 Dec 20 22:43 0000000B000000000000008B
-rw-------. 1 postgres postgres 16777216 Dec 20 22:43 0000000B000000000000008C
-rw-------. 1 postgres postgres 16777216 Dec 20 22:43 0000000B000000000000008D
-rw-------. 1 postgres postgres 16777216 Dec 20 22:43 0000000B000000000000008E
-rw-------. 1 postgres postgres 16777216 Dec 20 22:43 0000000B000000000000008F
-rw-------. 1 postgres postgres 16777216 Dec 20 22:43 0000000B0000000000000090
-rw-------. 1 postgres postgres   312 Dec 20 22:43 0000000B.history
drwx------. 2 postgres postgres   233 Dec 20 22:43 archive_status
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$psql
psql (12.3)
Type "help" for help.
postgres=# \c test
You are now connected to database "test" as user "postgres".
test=# select count(*) from test;
 count
-------
 2000
(1 row)
test=# select count(*) from test_pg_rman ;
 count
-------
 20000
(1 row)
test=# insert into test_pg_rman (id) select n from generate_series(20001,30000) n;
INSERT 0 10000
test=# \q
[postgres@node_206 /postgresql/pgsql]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/
=====================================================================
 StartTime      EndTime       Mode  Size  TLI Status
=====================================================================
2020-12-20 22:41:40 2020-12-20 22:41:43 INCR  390kB  10 OK
2020-12-20 22:39:35 2020-12-20 22:39:37 FULL 5451kB  10 OK
[postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -B /postgresql/pgsql/pg_rman_backups
INFO: copying database files
INFO: copying archived WAL files
INFO: backup complete
INFO: Please execute 'pg_rman validate' to verify the files are correctly copied.
INFO: start deleting old archived WAL files from ARCLOG_PATH (keep days = 10)
INFO: the threshold timestamp calculated by keep days is "2020-12-10 00:00:00"
INFO: start deleting old backup (keep generations = 3 AND keep after = 2020-10-21 00:00:00)
INFO: does not include the backup just taken
INFO: backup "2020-12-20 22:41:40" should be kept
DETAIL: This belongs to the 1st latest full backup.
INFO: backup "2020-12-20 22:39:35" should be kept
DETAIL: This is the 1st latest full backup.
[postgres@node_206 /postgresql/pgsql]$pg_rman validate -B /postgresql/pgsql/pg_rman_backups
INFO: validate: "2020-12-20 22:51:24" backup and archive log files by CRC
INFO: backup "2020-12-20 22:51:24" is valid
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/
=====================================================================
 StartTime      EndTime       Mode  Size  TLI Status
=====================================================================
2020-12-20 22:51:24 2020-12-20 22:51:27 FULL 6184kB  11 OK
2020-12-20 22:41:40 2020-12-20 22:41:43 INCR  390kB  10 OK
2020-12-20 22:39:35 2020-12-20 22:39:37 FULL 5451kB  10 OK
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_ctl stop
waiting for server to shut down.... done
server stopped
[postgres@node_206 /postgresql/pgsql]$ll
total 32
drwxr-xr-x. 2 postgres postgres 4096 Dec 20 22:51 archive_log
drwxrwxr-x. 2 postgres postgres  6 Nov 17 15:51 backups
drwxr-xr-x. 2 postgres postgres 4096 Nov 17 16:43 bin
drwx------. 19 postgres postgres 4096 Dec 20 22:51 data
drwxr-xr-x. 6 postgres postgres 4096 Nov 15 16:14 include
drwxr-xr-x. 4 postgres postgres 4096 Nov 17 06:37 lib
drwxr-xr-x. 2 postgres postgres 4096 Dec 20 22:43 pg_log
drwxrwxr-x. 5 postgres postgres 104 Dec 20 22:39 pg_rman_backups
drwxr-xr-x. 8 postgres postgres 4096 Nov 15 16:14 share
[postgres@node_206 /postgresql/pgsql]$mv data data_origin
[postgres@node_206 /postgresql/pgsql]$pg_ctl start
pg_ctl: directory "/postgresql/pgsql/data" does not exist
[postgres@node_206 /postgresql/pgsql]$pg_ctl start
pg_ctl: directory "/postgresql/pgsql/data" does not exist
[postgres@node_206 /postgresql/pgsql]$mv data_origin/ data
[postgres@node_206 /postgresql/pgsql]$pg_ctl start
waiting for server to start....2020-12-20 09:52:26.732 EST [60723] LOG: 00000: starting PostgreSQL 12.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
2020-12-20 09:52:26.732 EST [60723] LOCATION: PostmasterMain, postmaster.c:998
2020-12-20 09:52:26.738 EST [60723] LOG: 00000: listening on IPv4 address "0.0.0.0", port 5432
2020-12-20 09:52:26.738 EST [60723] LOCATION: StreamServerPort, pqcomm.c:593
2020-12-20 09:52:26.738 EST [60723] LOG: 00000: listening on IPv6 address "::", port 5432
2020-12-20 09:52:26.738 EST [60723] LOCATION: StreamServerPort, pqcomm.c:593
2020-12-20 09:52:26.740 EST [60723] LOG: 00000: listening on Unix socket "/tmp/.s.PGSQL.5432"
2020-12-20 09:52:26.740 EST [60723] LOCATION: StreamServerPort, pqcomm.c:587
2020-12-20 09:52:26.791 EST [60723] LOG: 00000: redirecting log output to logging collector process
2020-12-20 09:52:26.791 EST [60723] HINT: Future log output will appear in directory "/postgresql/pgsql/pg_log".
2020-12-20 09:52:26.791 EST [60723] LOCATION: SysLogger_Start, syslogger.c:675
 done
server started
[postgres@node_206 /postgresql/pgsql]$psql -U postgres
psql (12.3)
Type "help" for help.
postgres=# drop database test;
DROP DATABASE
postgres=# \q
[postgres@node_206 /postgresql/pgsql]$pg_ctl stop
waiting for server to shut down.... done
server stopped
[postgres@node_206 /postgresql/pgsql]$mv data/ data_origin
[postgres@node_206 /postgresql/pgsql]$pg_rman restore -B /postgresql/pgsql/pg_rman_backups/
WARNING: pg_controldata file "/postgresql/pgsql/data/global/pg_control" does not exist
INFO: the recovery target timeline ID is not given
INFO: use timeline ID of latest full backup as recovery target: 11
INFO: calculating timeline branches to be used to recovery target point
INFO: searching latest full backup which can be used as restore start point
INFO: found the full backup can be used as base in recovery: "2020-12-20 22:51:24"
INFO: copying online WAL files and server log files
INFO: clearing restore destination
INFO: validate: "2020-12-20 22:51:24" backup and archive log files by SIZE
INFO: backup "2020-12-20 22:51:24" is valid
INFO: restoring database files from the full mode backup "2020-12-20 22:51:24"
INFO: searching incremental backup to be restored
INFO: searching backup which contained archived WAL files to be restored
INFO: backup "2020-12-20 22:51:24" is valid
INFO: restoring WAL files from backup "2020-12-20 22:51:24"
INFO: restoring online WAL files and server log files
INFO: add recovery related options to postgresql.conf
INFO: generating recovery.signal
INFO: restore complete
HINT: Recovery will start automatically when the PostgreSQL server is started.
[postgres@node_206 /postgresql/pgsql]$pg_ctl start
waiting for server to start....2020-12-20 09:53:09.888 EST [60773] LOG: 00000: starting PostgreSQL 12.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
2020-12-20 09:53:09.888 EST [60773] LOCATION: PostmasterMain, postmaster.c:998
2020-12-20 09:53:09.889 EST [60773] LOG: 00000: listening on IPv4 address "0.0.0.0", port 5432
2020-12-20 09:53:09.889 EST [60773] LOCATION: StreamServerPort, pqcomm.c:593
2020-12-20 09:53:09.890 EST [60773] LOG: 00000: listening on IPv6 address "::", port 5432
2020-12-20 09:53:09.890 EST [60773] LOCATION: StreamServerPort, pqcomm.c:593
2020-12-20 09:53:09.893 EST [60773] LOG: 00000: listening on Unix socket "/tmp/.s.PGSQL.5432"
2020-12-20 09:53:09.893 EST [60773] LOCATION: StreamServerPort, pqcomm.c:587
2020-12-20 09:53:09.947 EST [60773] LOG: 00000: redirecting log output to logging collector process
2020-12-20 09:53:09.947 EST [60773] HINT: Future log output will appear in directory "/postgresql/pgsql/pg_log".
2020-12-20 09:53:09.947 EST [60773] LOCATION: SysLogger_Start, syslogger.c:675
 done
server started
[postgres@node_206 /postgresql/pgsql]$psql
psql (12.3)
Type "help" for help.
postgres=# \c test
You are now connected to database "test" as user "postgres".
test=# \dt
      List of relations
 Schema |   Name   | Type | Owner 
--------+--------------+-------+----------
 public | test     | table | postgres
 public | test_pg_rman | table | postgres
(2 rows)
test=# select count(*) from test_pg_Rman;
 count
-------
 30000
(1 row)
test=# select count(*) from test;
 count
-------
 2000
(1 row)
test=#
test=# select * from pg_is_in_recovery();
 pg_is_in_recovery
-------------------
 t
(1 row)
test=# select pg_wal_replay_resume();
 pg_wal_replay_resume
----------------------
 
(1 row)
test=# select * from pg_is_in_recovery();
 pg_is_in_recovery
-------------------
 f
(1 row)
test=# \q
[postgres@node_206 /postgresql/pgsql]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/
=====================================================================
 StartTime      EndTime       Mode  Size  TLI Status
=====================================================================
2020-12-20 22:51:24 2020-12-20 22:51:27 FULL 6184kB  11 OK
2020-12-20 22:41:40 2020-12-20 22:41:43 INCR  390kB  10 OK
2020-12-20 22:39:35 2020-12-20 22:39:37 FULL 5451kB  10 OK
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_rman restore -B /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-12-20 22:39:35'
ERROR: PostgreSQL server is running
HINT: Please stop PostgreSQL server before executing restore.
[postgres@node_206 /postgresql/pgsql]$pg_ctl stop
waiting for server to shut down.... done
server stopped
[postgres@node_206 /postgresql/pgsql]$pg_rman restore -B /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-12-20 22:39:35'
ERROR: cannot do restore
DETAIL: There is no valid full backup which can be used for given recovery condition.
[postgres@node_206 /postgresql/pgsql]$pg_rman restore -B /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-12-20 22:39:36'
ERROR: cannot do restore
DETAIL: There is no valid full backup which can be used for given recovery condition.
[postgres@node_206 /postgresql/pgsql]$pg_rman restore -B /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-12-20 22:39:34'
ERROR: cannot do restore
DETAIL: There is no valid full backup which can be used for given recovery condition.
[postgres@node_206 /postgresql/pgsql]$pg_rman restore -B /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-12-20 22:39:20'
ERROR: cannot do restore
DETAIL: There is no valid full backup which can be used for given recovery condition.
[postgres@node_206 /postgresql/pgsql]$pg_rman restore -B /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-12-20 22:39:24
> ^C
[postgres@node_206 /postgresql/pgsql]$pg_rman restore -B /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-12-20 22:39:24'
ERROR: cannot do restore
DETAIL: There is no valid full backup which can be used for given recovery condition.
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_rman restore -B /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-12-20 22:39:24' -P
ERROR: cannot do restore
DETAIL: There is no valid full backup which can be used for given recovery condition.
[postgres@node_206 /postgresql/pgsql]$pg_rman restore -B /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-12-20 22:39:24' -P-v
pg_rman: invalid option -- '-'
ERROR: option is not specified
HINT: Try "pg_rman --help" for more information.
[postgres@node_206 /postgresql/pgsql]$pg_rman restore -B /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-12-20 22:39:24' -Pv
========================================
restore start
ERROR: cannot do restore
DETAIL: There is no valid full backup which can be used for given recovery condition.
[postgres@node_206 /postgresql/pgsql]$pg_rman restore -B /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-12-20 22:39:24' -Pv --debug
========================================
restore start
DEBUG: the current timeline ID of database cluster is 12
ERROR: cannot do restore
DETAIL: There is no valid full backup which can be used for given recovery condition.
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/ details
ERROR: arguments are invalid. near "details"
[postgres@node_206 /postgresql/pgsql]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/ detail
======================================================================================================================
 StartTime      EndTime       Mode  Data ArcLog SrvLog  Total Compressed CurTLI ParentTLI Status
======================================================================================================================
2020-12-20 22:51:24 2020-12-20 22:51:27 FULL  45MB  117MB  ---- 6184kB    true   11     10 OK
2020-12-20 22:41:40 2020-12-20 22:41:43 INCR 1237kB  33MB  ----  390kB    true   10     0 OK
2020-12-20 22:39:35 2020-12-20 22:39:37 FULL  44MB  33MB  ---- 5451kB    true   10     0 OK
[postgres@node_206 /postgresql/pgsql]$ls
archive_log backups bin data data_origin include lib pg_log pg_rman_backups share
[postgres@node_206 /postgresql/pgsql]$pg_controldata /postgresql/pgsql/data/
pg_control version number:      1201
Catalog version number:        201909212
Database system identifier:      6895281636782426835
Database cluster state:        shut down
pg_control last modified:       Sun 20 Dec 2020 10:54:14 PM CST
Latest checkpoint location:      0/89000028
Latest checkpoint's REDO location:  0/89000028
Latest checkpoint's REDO WAL file:  0000000C0000000000000089
Latest checkpoint's TimeLineID:    12
Latest checkpoint's PrevTimeLineID:  12
Latest checkpoint's full_page_writes: on
Latest checkpoint's NextXID:     0:7755
Latest checkpoint's NextOID:     25080
Latest checkpoint's NextMultiXactId: 1
Latest checkpoint's NextMultiOffset: 0
Latest checkpoint's oldestXID:    479
Latest checkpoint's oldestXID's DB:  1
Latest checkpoint's oldestActiveXID: 0
Latest checkpoint's oldestMultiXid:  1
Latest checkpoint's oldestMulti's DB: 1
Latest checkpoint's oldestCommitTsXid:0
Latest checkpoint's newestCommitTsXid:0
Time of latest checkpoint:      Sun 20 Dec 2020 10:54:14 PM CST
Fake LSN counter for unlogged rels:  0/3E8
Minimum recovery ending location:   0/0
Min recovery ending loc's timeline:  0
Backup start location:        0/0
Backup end location:         0/0
End-of-backup record required:    no
wal_level setting:          replica
wal_log_hints setting:        on
max_connections setting:       200
max_worker_processes setting:     8
max_wal_senders setting:       10
max_prepared_xacts setting:      0
max_locks_per_xact setting:      64
track_commit_timestamp setting:    off
Maximum data alignment:        8
Database block size:         8192
Blocks per segment of large relation: 131072
WAL block size:            8192
Bytes per WAL segment:        16777216
Maximum length of identifiers:    64
Maximum columns in an index:     32
Maximum size of a TOAST chunk:    1996
Size of a large-object chunk:     2048
Date/time type storage:        64-bit integers
Float4 argument passing:       by value
Float8 argument passing:       by value
Data page checksum version:      0
Mock authentication nonce:      0e803fe626d0bf49403235ba1f4f8a665eb48d4d847cb7863dcad401e65676ca
[postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -B /postgresql/pgsql/pg_rman_backups
ERROR: could not connect to database postgres: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
[postgres@node_206 /postgresql/pgsql]$pg_ctl start
waiting for server to start....2020-12-20 09:56:02.612 EST [60839] LOG: 00000: starting PostgreSQL 12.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
2020-12-20 09:56:02.612 EST [60839] LOCATION: PostmasterMain, postmaster.c:998
2020-12-20 09:56:02.613 EST [60839] LOG: 00000: listening on IPv4 address "0.0.0.0", port 5432
2020-12-20 09:56:02.613 EST [60839] LOCATION: StreamServerPort, pqcomm.c:593
2020-12-20 09:56:02.613 EST [60839] LOG: 00000: listening on IPv6 address "::", port 5432
2020-12-20 09:56:02.613 EST [60839] LOCATION: StreamServerPort, pqcomm.c:593
2020-12-20 09:56:02.615 EST [60839] LOG: 00000: listening on Unix socket "/tmp/.s.PGSQL.5432"
2020-12-20 09:56:02.615 EST [60839] LOCATION: StreamServerPort, pqcomm.c:587
2020-12-20 09:56:02.664 EST [60839] LOG: 00000: redirecting log output to logging collector process
2020-12-20 09:56:02.664 EST [60839] HINT: Future log output will appear in directory "/postgresql/pgsql/pg_log".
2020-12-20 09:56:02.664 EST [60839] LOCATION: SysLogger_Start, syslogger.c:675
 done
server started
[postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -B /postgresql/pgsql/pg_rman_backups
INFO: copying database files
INFO: copying archived WAL files
INFO: backup complete
INFO: Please execute 'pg_rman validate' to verify the files are correctly copied.
INFO: start deleting old archived WAL files from ARCLOG_PATH (keep days = 10)
INFO: the threshold timestamp calculated by keep days is "2020-12-10 00:00:00"
INFO: start deleting old backup (keep generations = 3 AND keep after = 2020-10-21 00:00:00)
INFO: does not include the backup just taken
WARNING: backup "2020-12-20 22:55:57" is not taken into account
DETAIL: This is not a valid backup.
INFO: backup "2020-12-20 22:51:24" should be kept
DETAIL: This is the 1st latest full backup.
INFO: backup "2020-12-20 22:41:40" should be kept
DETAIL: This belongs to the 2nd latest full backup.
INFO: backup "2020-12-20 22:39:35" should be kept
DETAIL: This is the 2nd latest full backup.
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_rman restore -B /postgresql/pgsql/data/ --recovery-target-time='2020-11-18 00:10:49' -A /postgresql/pgsql/archive_log/ -S /postgresql/pgsql/pg_log/
ERROR: could not open file "/postgresql/pgsql/data//pg_rman.ini": No such file or directory
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/ detail
======================================================================================================================
 StartTime      EndTime       Mode  Data ArcLog SrvLog  Total Compressed CurTLI ParentTLI Status
======================================================================================================================
2020-12-20 22:56:05 2020-12-20 22:56:09 FULL  45MB  201MB  ---- 6251kB    true   12     11 DONE
2020-12-20 22:55:57 2020-12-20 22:55:57 FULL  ----  ----  ----   0B    true    0     0 ERROR
2020-12-20 22:51:24 2020-12-20 22:51:27 FULL  45MB  117MB  ---- 6184kB    true   11     10 OK
2020-12-20 22:41:40 2020-12-20 22:41:43 INCR 1237kB  33MB  ----  390kB    true   10     0 OK
2020-12-20 22:39:35 2020-12-20 22:39:37 FULL  44MB  33MB  ---- 5451kB    true   10     0 OK
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_ctl start
pg_ctl: another server might be running; trying to start server anyway
waiting for server to start....2020-12-20 10:01:14.923 EST [60948] FATAL: F0001: lock file "postmaster.pid" already exists
2020-12-20 10:01:14.923 EST [60948] HINT: Is another postmaster (PID 60839) running in data directory "/postgresql/pgsql/data"?
2020-12-20 10:01:14.923 EST [60948] LOCATION: CreateLockFile, miscinit.c:1034
 stopped waiting
pg_ctl: could not start server
Examine the log output.
[postgres@node_206 /postgresql/pgsql]$psql -U postgres -d test
psql (12.3)
Type "help" for help.
test=# create table test2 (like test);
CREATE TABLE
test=# \d test2
             Table "public.test2"
 Column |      Type       | Collation | Nullable | Default
----------+-----------------------------+-----------+----------+---------
 id    | integer           |      |     |
 crt_time | timestamp without time zone |      |     |
test=# insert into test2 (id ) select n from generate_series(1,1000000) n;
INSERT 0 1000000
test=# \q
[postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=incremental -B /postgresql/pgsql/pg_rman_backups
INFO: copying database files
ERROR: cannot take an incremental backup
DETAIL: There is no validated full backup with current timeline.
HINT: Please take a full backup and validate it before doing an incremental backup. Or use with --full-backup-on-error command line option.
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -B /postgresql/pgsql/pg_rman_backups
INFO: copying database files
INFO: copying archived WAL files
INFO: backup complete
INFO: Please execute 'pg_rman validate' to verify the files are correctly copied.
INFO: start deleting old archived WAL files from ARCLOG_PATH (keep days = 10)
INFO: the threshold timestamp calculated by keep days is "2020-12-10 00:00:00"
INFO: start deleting old backup (keep generations = 3 AND keep after = 2020-10-21 00:00:00)
INFO: does not include the backup just taken
WARNING: backup "2020-12-20 23:01:58" is not taken into account
DETAIL: This is not a valid backup.
WARNING: backup "2020-12-20 22:56:05" is not taken into account
DETAIL: This is not a valid backup.
WARNING: backup "2020-12-20 22:55:57" is not taken into account
DETAIL: This is not a valid backup.
INFO: backup "2020-12-20 22:51:24" should be kept
DETAIL: This is the 1st latest full backup.
INFO: backup "2020-12-20 22:41:40" should be kept
DETAIL: This belongs to the 2nd latest full backup.
INFO: backup "2020-12-20 22:39:35" should be kept
DETAIL: This is the 2nd latest full backup.
[postgres@node_206 /postgresql/pgsql]$pg_rman validate -B /postgresql/pgsql/pg_rman_backups
INFO: validate: "2020-12-20 22:56:05" backup and archive log files by CRC
INFO: backup "2020-12-20 22:56:05" is valid
INFO: validate: "2020-12-20 23:02:07" backup and archive log files by CRC
INFO: backup "2020-12-20 23:02:07" is valid
[postgres@node_206 /postgresql/pgsql]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/ detail
======================================================================================================================
 StartTime      EndTime       Mode  Data ArcLog SrvLog  Total Compressed CurTLI ParentTLI Status
======================================================================================================================
2020-12-20 23:02:07 2020-12-20 23:02:13 FULL  82MB  301MB  ----  23MB    true   12     11 OK
2020-12-20 23:01:58 2020-12-20 23:01:58 INCR   0B  ----  ----   0B    true   12     11 ERROR
2020-12-20 22:56:05 2020-12-20 22:56:09 FULL  45MB  201MB  ---- 6251kB    true   12     11 OK
2020-12-20 22:55:57 2020-12-20 22:55:57 FULL  ----  ----  ----   0B    true    0     0 ERROR
2020-12-20 22:51:24 2020-12-20 22:51:27 FULL  45MB  117MB  ---- 6184kB    true   11     10 OK
2020-12-20 22:41:40 2020-12-20 22:41:43 INCR 1237kB  33MB  ----  390kB    true   10     0 OK
2020-12-20 22:39:35 2020-12-20 22:39:37 FULL  44MB  33MB  ---- 5451kB    true   10     0 OK
[postgres@node_206 /postgresql/pgsql]$pg_ctl stop
waiting for server to shut down.... done
server stopped
[postgres@node_206 /postgresql/pgsql]$pg_rman restore -B /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-12-20 22:39:24' -Pv --debug
[postgres@node_206 /postgresql/pgsql]$pg_rman restore -B /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-12-20 22:39:24' -Pv
[postgres@node_206 /postgresql/pgsql]$pg_rman restore -B /postgresql/pgsql/pg_rman_backups/ --recovery-target-time='2020-12-20 22:56:05'
INFO: the recovery target timeline ID is not given
INFO: use timeline ID of current database cluster as recovery target: 12
INFO: calculating timeline branches to be used to recovery target point
INFO: searching latest full backup which can be used as restore start point
INFO: found the full backup can be used as base in recovery: "2020-12-20 22:51:24"
INFO: copying online WAL files and server log files
INFO: clearing restore destination
INFO: validate: "2020-12-20 22:51:24" backup and archive log files by SIZE
INFO: backup "2020-12-20 22:51:24" is valid
INFO: restoring database files from the full mode backup "2020-12-20 22:51:24"
INFO: searching incremental backup to be restored
INFO: searching backup which contained archived WAL files to be restored
INFO: backup "2020-12-20 22:51:24" is valid
INFO: restoring WAL files from backup "2020-12-20 22:51:24"
INFO: backup "2020-12-20 22:56:05" is valid
INFO: restoring WAL files from backup "2020-12-20 22:56:05"
INFO: backup "2020-12-20 23:02:07" is valid
INFO: restoring WAL files from backup "2020-12-20 23:02:07"
INFO: restoring online WAL files and server log files
INFO: add recovery related options to postgresql.conf
INFO: generating recovery.signal
INFO: restore complete
HINT: Recovery will start automatically when the PostgreSQL server is started.
[postgres@node_206 /postgresql/pgsql]$pg_ctl start
waiting for server to start....2020-12-20 10:03:39.933 EST [61032] LOG: 00000: starting PostgreSQL 12.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
2020-12-20 10:03:39.933 EST [61032] LOCATION: PostmasterMain, postmaster.c:998
2020-12-20 10:03:39.935 EST [61032] LOG: 00000: listening on IPv4 address "0.0.0.0", port 5432
2020-12-20 10:03:39.935 EST [61032] LOCATION: StreamServerPort, pqcomm.c:593
2020-12-20 10:03:39.936 EST [61032] LOG: 00000: listening on IPv6 address "::", port 5432
2020-12-20 10:03:39.936 EST [61032] LOCATION: StreamServerPort, pqcomm.c:593
2020-12-20 10:03:39.941 EST [61032] LOG: 00000: listening on Unix socket "/tmp/.s.PGSQL.5432"
2020-12-20 10:03:39.941 EST [61032] LOCATION: StreamServerPort, pqcomm.c:587
2020-12-20 10:03:39.982 EST [61032] LOG: 00000: redirecting log output to logging collector process
2020-12-20 10:03:39.982 EST [61032] HINT: Future log output will appear in directory "/postgresql/pgsql/pg_log".
2020-12-20 10:03:39.982 EST [61032] LOCATION: SysLogger_Start, syslogger.c:675
 done
server started
[postgres@node_206 /postgresql/pgsql]$psql -d test
psql (12.3)
Type "help" for help.
test=# \dt
      List of relations
 Schema |   Name   | Type | Owner 
--------+--------------+-------+----------
 public | test     | table | postgres
 public | test_pg_rman | table | postgres
(2 rows)
test=# select pg_wal_replay_resume();
 pg_wal_replay_resume
----------------------
 
(1 row)
test=#
test=# select * from pg_is_in_recovery();
 pg_is_in_recovery
-------------------
 f
(1 row)
test=# \q
[postgres@node_206 /postgresql/pgsql]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/ detail
======================================================================================================================
 StartTime      EndTime       Mode  Data ArcLog SrvLog  Total Compressed CurTLI ParentTLI Status
======================================================================================================================
2020-12-20 23:02:07 2020-12-20 23:02:13 FULL  82MB  301MB  ----  23MB    true   12     11 OK
2020-12-20 23:01:58 2020-12-20 23:01:58 INCR   0B  ----  ----   0B    true   12     11 ERROR
2020-12-20 22:56:05 2020-12-20 22:56:09 FULL  45MB  201MB  ---- 6251kB    true   12     11 OK
2020-12-20 22:55:57 2020-12-20 22:55:57 FULL  ----  ----  ----   0B    true    0     0 ERROR
2020-12-20 22:51:24 2020-12-20 22:51:27 FULL  45MB  117MB  ---- 6184kB    true   11     10 OK
2020-12-20 22:41:40 2020-12-20 22:41:43 INCR 1237kB  33MB  ----  390kB    true   10     0 OK
2020-12-20 22:39:35 2020-12-20 22:39:37 FULL  44MB  33MB  ---- 5451kB    true   10     0 OK
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_controldata /postgresql/pgsql/data/
pg_control version number:      1201
Catalog version number:        201909212
Database system identifier:      6895281636782426835
Database cluster state:        in production
pg_control last modified:       Sun 20 Dec 2020 11:03:50 PM CST
Latest checkpoint location:      0/8B000028
Latest checkpoint's REDO location:  0/8B000028
Latest checkpoint's REDO WAL file:  0000000D000000000000008B
Latest checkpoint's TimeLineID:    13
Latest checkpoint's PrevTimeLineID:  12
Latest checkpoint's full_page_writes: on
Latest checkpoint's NextXID:     0:7755
Latest checkpoint's NextOID:     25080
Latest checkpoint's NextMultiXactId: 1
Latest checkpoint's NextMultiOffset: 0
Latest checkpoint's oldestXID:    479
Latest checkpoint's oldestXID's DB:  1
Latest checkpoint's oldestActiveXID: 0
Latest checkpoint's oldestMultiXid:  1
Latest checkpoint's oldestMulti's DB: 1
Latest checkpoint's oldestCommitTsXid:0
Latest checkpoint's newestCommitTsXid:0
Time of latest checkpoint:      Sun 20 Dec 2020 11:03:50 PM CST
Fake LSN counter for unlogged rels:  0/3E8
Minimum recovery ending location:   0/0
Min recovery ending loc's timeline:  0
Backup start location:        0/0
Backup end location:         0/0
End-of-backup record required:    no
wal_level setting:          replica
wal_log_hints setting:        on
max_connections setting:       200
max_worker_processes setting:     8
max_wal_senders setting:       10
max_prepared_xacts setting:      0
max_locks_per_xact setting:      64
track_commit_timestamp setting:    off
Maximum data alignment:        8
Database block size:         8192
Blocks per segment of large relation: 131072
WAL block size:            8192
Bytes per WAL segment:        16777216
Maximum length of identifiers:    64
Maximum columns in an index:     32
Maximum size of a TOAST chunk:    1996
Size of a large-object chunk:     2048
Date/time type storage:        64-bit integers
Float4 argument passing:       by value
Float8 argument passing:       by value
Data page checksum version:      0
Mock authentication nonce:      0e803fe626d0bf49403235ba1f4f8a665eb48d4d847cb7863dcad401e65676ca
[postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -B /postgresql/pgsql/pg_rman_backups
INFO: copying database files
INFO: copying archived WAL files
INFO: backup complete
INFO: Please execute 'pg_rman validate' to verify the files are correctly copied.
INFO: start deleting old archived WAL files from ARCLOG_PATH (keep days = 10)
INFO: the threshold timestamp calculated by keep days is "2020-12-10 00:00:00"
INFO: start deleting old backup (keep generations = 3 AND keep after = 2020-10-21 00:00:00)
INFO: does not include the backup just taken
INFO: backup "2020-12-20 23:02:07" should be kept
DETAIL: This is the 1st latest full backup.
WARNING: backup "2020-12-20 23:01:58" is not taken into account
DETAIL: This is not a valid backup.
INFO: backup "2020-12-20 22:56:05" should be kept
DETAIL: This is the 2nd latest full backup.
WARNING: backup "2020-12-20 22:55:57" is not taken into account
DETAIL: This is not a valid backup.
INFO: backup "2020-12-20 22:51:24" should be kept
DETAIL: This is the 3rd latest full backup.
INFO: backup "2020-12-20 22:41:40" should be kept
DETAIL: This is taken after "2020-10-21 00:00:00".
INFO: backup "2020-12-20 22:39:35" should be kept
DETAIL: This is taken after "2020-10-21 00:00:00".
[postgres@node_206 /postgresql/pgsql]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/ detail
======================================================================================================================
 StartTime      EndTime       Mode  Data ArcLog SrvLog  Total Compressed CurTLI ParentTLI Status
======================================================================================================================
2020-12-20 23:04:19 2020-12-20 23:04:25 FULL  45MB  352MB  ----  19MB    true   13     12 DONE
2020-12-20 23:02:07 2020-12-20 23:02:13 FULL  82MB  301MB  ----  23MB    true   12     11 OK
2020-12-20 23:01:58 2020-12-20 23:01:58 INCR   0B  ----  ----   0B    true   12     11 ERROR
2020-12-20 22:56:05 2020-12-20 22:56:09 FULL  45MB  201MB  ---- 6251kB    true   12     11 OK
2020-12-20 22:55:57 2020-12-20 22:55:57 FULL  ----  ----  ----   0B    true    0     0 ERROR
2020-12-20 22:51:24 2020-12-20 22:51:27 FULL  45MB  117MB  ---- 6184kB    true   11     10 OK
2020-12-20 22:41:40 2020-12-20 22:41:43 INCR 1237kB  33MB  ----  390kB    true   10     0 OK
2020-12-20 22:39:35 2020-12-20 22:39:37 FULL  44MB  33MB  ---- 5451kB    true   10     0 OK
[postgres@node_206 /postgresql/pgsql]$pg_rman validate -B /postgresql/pgsql/pg_rman_backups
INFO: validate: "2020-12-20 23:04:19" backup and archive log files by CRC
INFO: backup "2020-12-20 23:04:19" is valid
[postgres@node_206 /postgresql/pgsql]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/ detail
======================================================================================================================
 StartTime      EndTime       Mode  Data ArcLog SrvLog  Total Compressed CurTLI ParentTLI Status
======================================================================================================================
2020-12-20 23:04:19 2020-12-20 23:04:25 FULL  45MB  352MB  ----  19MB    true   13     12 OK
2020-12-20 23:02:07 2020-12-20 23:02:13 FULL  82MB  301MB  ----  23MB    true   12     11 OK
2020-12-20 23:01:58 2020-12-20 23:01:58 INCR   0B  ----  ----   0B    true   12     11 ERROR
2020-12-20 22:56:05 2020-12-20 22:56:09 FULL  45MB  201MB  ---- 6251kB    true   12     11 OK
2020-12-20 22:55:57 2020-12-20 22:55:57 FULL  ----  ----  ----   0B    true    0     0 ERROR
2020-12-20 22:51:24 2020-12-20 22:51:27 FULL  45MB  117MB  ---- 6184kB    true   11     10 OK
2020-12-20 22:41:40 2020-12-20 22:41:43 INCR 1237kB  33MB  ----  390kB    true   10     0 OK
2020-12-20 22:39:35 2020-12-20 22:39:37 FULL  44MB  33MB  ---- 5451kB    true   10     0 OK
[postgres@node_206 /postgresql/pgsql]$psql -d test
psql (12.3)
Type "help" for help.
test=# \dt
      List of relations
 Schema |   Name   | Type | Owner 
--------+--------------+-------+----------
 public | test     | table | postgres
 public | test_pg_rman | table | postgres
(2 rows)
test=# create table test2(like test);
CREATE TABLE
test=# insert into test2 select * from test;
INSERT 0 2000
test=# \q
[postgres@node_206 /postgresql/pgsql]$pg_rman backup -bi -B /postgresql/pgsql/pg_rman_backups
INFO: copying database files
INFO: copying archived WAL files
INFO: backup complete
INFO: Please execute 'pg_rman validate' to verify the files are correctly copied.
INFO: start deleting old archived WAL files from ARCLOG_PATH (keep days = 10)
INFO: the threshold timestamp calculated by keep days is "2020-12-10 00:00:00"
INFO: start deleting old backup (keep generations = 3 AND keep after = 2020-10-21 00:00:00)
INFO: does not include the backup just taken
INFO: backup "2020-12-20 23:04:19" should be kept
DETAIL: This is the 1st latest full backup.
INFO: backup "2020-12-20 23:02:07" should be kept
DETAIL: This is the 2nd latest full backup.
WARNING: backup "2020-12-20 23:01:58" is not taken into account
DETAIL: This is not a valid backup.
INFO: backup "2020-12-20 22:56:05" should be kept
DETAIL: This is the 3rd latest full backup.
WARNING: backup "2020-12-20 22:55:57" is not taken int account
DETAIL: This is not valid backup.
INFO: backup "2020-12-20 22:51:24" should be kept
DETAIL: This is taken after "2020-10-21 00:00:00".
INFO: backup "2020-12-20 22:41:40" should be kept
DETAIL: This is taken after "2020-10-21 00:00:00".
INFO: backup "2020-12-20 22:39:35" should be kept
DETAIL: This is taken after "2020-10-21 00:00:00".
[postgres@node_206 /postgresql/pgsql]$pg_rman validate -B /postgresql/pgsql/pg_rman_backups
INFO: validate: "2020-12-20 23:06:51" backup and archive log files by CRC
INFO: backup "2020-12-20 23:06:51" is valid
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/ detail
======================================================================================================================
 StartTime      EndTime       Mode  Data ArcLog SrvLog  Total Compressed CurTLI ParentTLI Status
======================================================================================================================
2020-12-20 23:06:51 2020-12-20 23:06:53 INCR 2465kB  33MB  ----  112kB    true   13     12 OK
2020-12-20 23:04:19 2020-12-20 23:04:25 FULL  45MB  352MB  ----  19MB    true   13     12 OK
2020-12-20 23:02:07 2020-12-20 23:02:13 FULL  82MB  301MB  ----  23MB    true   12     11 OK
2020-12-20 23:01:58 2020-12-20 23:01:58 INCR   0B  ----  ----   0B    true   12     11 ERROR
2020-12-20 22:56:05 2020-12-20 22:56:09 FULL  45MB  201MB  ---- 6251kB    true   12     11 OK
2020-12-20 22:55:57 2020-12-20 22:55:57 FULL  ----  ----  ----   0B    true    0     0 ERROR
2020-12-20 22:51:24 2020-12-20 22:51:27 FULL  45MB  117MB  ---- 6184kB    true   11     10 OK
2020-12-20 22:41:40 2020-12-20 22:41:43 INCR 1237kB  33MB  ----  390kB    true   10     0 OK
2020-12-20 22:39:35 2020-12-20 22:39:37 FULL  44MB  33MB  ---- 5451kB    true   10     0 OK
[postgres@node_206 /postgresql/pgsql]$psql -d test
psql (12.3)
Type "help" for help.
test=# create table test34(like test);
CREATE TABLE
test=# create table test3(like test);
CREATE TABLE
test=# insert into test3 select * from test;
INSERT 0 2000
test=# \q
[postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -B /postgresql/pgsql/pg_rman_backups
INFO: copying database files
INFO: copying archived WAL files
INFO: backup complete
INFO: Please execute 'pg_rman validate' to verify the files are correctly copied.
INFO: start deleting old archived WAL files from ARCLOG_PATH (keep days = 10)
INFO: the threshold timestamp calculated by keep days is "2020-12-10 00:00:00"
INFO: start deleting old backup (keep generations = 3 AND keep after = 2020-10-21 00:00:00)
INFO: does not include the backup just taken
INFO: backup "2020-12-20 23:06:51" should be kept
DETAIL: This belongs to the 1st latest full backup.
INFO: backup "2020-12-20 23:04:19" should be kept
DETAIL: This is the 1st latest full backup.
INFO: backup "2020-12-20 23:02:07" should be kept
DETAIL: This is the 2nd latest full backup.
WARNING: backup "2020-12-20 23:01:58" is not taken into account
DETAIL: This is not a valid backup.
INFO: backup "2020-12-20 22:56:05" should be kept
DETAIL: This is the 3rd latest full backup.
WARNING: backup "2020-12-20 22:55:57" is not taken int account
DETAIL: This is not valid backup.
INFO: backup "2020-12-20 22:51:24" should be kept
DETAIL: This is taken after "2020-10-21 00:00:00".
INFO: backup "2020-12-20 22:41:40" should be kept
DETAIL: This is taken after "2020-10-21 00:00:00".
INFO: backup "2020-12-20 22:39:35" should be kept
DETAIL: This is taken after "2020-10-21 00:00:00".
[postgres@node_206 /postgresql/pgsql]$pg_rman validate -B /postgresql/pgsql/pg_rman_backups
INFO: validate: "2020-12-20 23:08:23" backup and archive log files by CRC
INFO: backup "2020-12-20 23:08:23" is valid
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/ detail
======================================================================================================================
 StartTime      EndTime       Mode  Data ArcLog SrvLog  Total Compressed CurTLI ParentTLI Status
======================================================================================================================
2020-12-20 23:08:23 2020-12-20 23:08:25 FULL  46MB  33MB  ---- 5495kB    true   13     12 OK
2020-12-20 23:06:51 2020-12-20 23:06:53 INCR 2465kB  33MB  ----  112kB    true   13     12 OK
2020-12-20 23:04:19 2020-12-20 23:04:25 FULL  45MB  352MB  ----  19MB    true   13     12 OK
2020-12-20 23:02:07 2020-12-20 23:02:13 FULL  82MB  301MB  ----  23MB    true   12     11 OK
2020-12-20 23:01:58 2020-12-20 23:01:58 INCR   0B  ----  ----   0B    true   12     11 ERROR
2020-12-20 22:56:05 2020-12-20 22:56:09 FULL  45MB  201MB  ---- 6251kB    true   12     11 OK
2020-12-20 22:55:57 2020-12-20 22:55:57 FULL  ----  ----  ----   0B    true    0     0 ERROR
2020-12-20 22:51:24 2020-12-20 22:51:27 FULL  45MB  117MB  ---- 6184kB    true   11     10 OK
2020-12-20 22:41:40 2020-12-20 22:41:43 INCR 1237kB  33MB  ----  390kB    true   10     0 OK
2020-12-20 22:39:35 2020-12-20 22:39:37 FULL  44MB  33MB  ---- 5451kB    true   10     0 OK
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$psql -d test
psql (12.3)
Type "help" for help.
test=# creat table test4(like test);
ERROR: syntax error at or near "creat"
LINE 1: creat table test4(like test);
    ^
test=# create table test4(like test);
CREATE TABLE
test=# insert into test4 select * from test;
INSERT 0 2000
test=#
test=# \q
[postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -B /postgresql/pgsql/pg_rman_backups
INFO: copying database files
INFO: copying archived WAL files
INFO: backup complete
INFO: Please execute 'pg_rman validate' to verify the files are correctly copied.
INFO: start deleting old archived WAL files from ARCLOG_PATH (keep days = 10)
INFO: the threshold timestamp calculated by keep days is "2020-12-10 00:00:00"
INFO: start deleting old backup (keep generations = 3 AND keep after = 2020-10-21 00:00:00)
INFO: does not include the backup just taken
INFO: backup "2020-12-20 23:08:23" should be kept
DETAIL: This is the 1st latest full backup.
INFO: backup "2020-12-20 23:06:51" should be kept
DETAIL: This belongs to the 2nd latest full backup.
INFO: backup "2020-12-20 23:04:19" should be kept
DETAIL: This is the 2nd latest full backup.
INFO: backup "2020-12-20 23:02:07" should be kept
DETAIL: This is the 3rd latest full backup.
WARNING: backup "2020-12-20 23:01:58" is not taken int account
DETAIL: This is not valid backup.
INFO: backup "2020-12-20 22:56:05" should be kept
DETAIL: This is taken after "2020-10-21 00:00:00".
WARNING: backup "2020-12-20 22:55:57" is not taken int account
DETAIL: This is not valid backup.
INFO: backup "2020-12-20 22:51:24" should be kept
DETAIL: This is taken after "2020-10-21 00:00:00".
INFO: backup "2020-12-20 22:41:40" should be kept
DETAIL: This is taken after "2020-10-21 00:00:00".
INFO: backup "2020-12-20 22:39:35" should be kept
DETAIL: This is taken after "2020-10-21 00:00:00".
[postgres@node_206 /postgresql/pgsql]$pg_rman validate -B /postgresql/pgsql/pg_rman_backups
INFO: validate: "2020-12-20 23:09:48" backup and archive log files by CRC
INFO: backup "2020-12-20 23:09:48" is valid
[postgres@node_206 /postgresql/pgsql]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/ detail
======================================================================================================================
 StartTime      EndTime       Mode  Data ArcLog SrvLog  Total Compressed CurTLI ParentTLI Status
======================================================================================================================
2020-12-20 23:09:48 2020-12-20 23:09:50 FULL  46MB  33MB  ---- 5507kB    true   13     12 OK
2020-12-20 23:08:23 2020-12-20 23:08:25 FULL  46MB  33MB  ---- 5495kB    true   13     12 OK
2020-12-20 23:06:51 2020-12-20 23:06:53 INCR 2465kB  33MB  ----  112kB    true   13     12 OK
2020-12-20 23:04:19 2020-12-20 23:04:25 FULL  45MB  352MB  ----  19MB    true   13     12 OK
2020-12-20 23:02:07 2020-12-20 23:02:13 FULL  82MB  301MB  ----  23MB    true   12     11 OK
2020-12-20 23:01:58 2020-12-20 23:01:58 INCR   0B  ----  ----   0B    true   12     11 ERROR
2020-12-20 22:56:05 2020-12-20 22:56:09 FULL  45MB  201MB  ---- 6251kB    true   12     11 OK
2020-12-20 22:55:57 2020-12-20 22:55:57 FULL  ----  ----  ----   0B    true    0     0 ERROR
2020-12-20 22:51:24 2020-12-20 22:51:27 FULL  45MB  117MB  ---- 6184kB    true   11     10 OK
2020-12-20 22:41:40 2020-12-20 22:41:43 INCR 1237kB  33MB  ----  390kB    true   10     0 OK
2020-12-20 22:39:35 2020-12-20 22:39:37 FULL  44MB  33MB  ---- 5451kB    true   10     0 OK
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$psql -d test
psql (12.3)
Type "help" for help.
test=# create table test5(like test);
CREATE TABLE
test=# insert into test5 select * from test;
INSERT 0 2000
test=# \q
[postgres@node_206 /postgresql/pgsql]$pg_rman backup --backup-mode=full -B /postgresql/pgsql/pg_rman_backups
INFO: copying database files
INFO: copying archived WAL files
INFO: backup complete
INFO: Please execute 'pg_rman validate' to verify the files are correctly copied.
INFO: start deleting old archived WAL files from ARCLOG_PATH (keep days = 10)
INFO: the threshold timestamp calculated by keep days is "2020-12-10 00:00:00"
INFO: start deleting old backup (keep generations = 3 AND keep after = 2020-10-21 00:00:00)
INFO: does not include the backup just taken
INFO: backup "2020-12-20 23:09:48" should be kept
DETAIL: This is the 1st latest full backup.
INFO: backup "2020-12-20 23:08:23" should be kept
DETAIL: This is the 2nd latest full backup.
INFO: backup "2020-12-20 23:06:51" should be kept
DETAIL: This belongs to the 3rd latest full backup.
INFO: backup "2020-12-20 23:04:19" should be kept
DETAIL: This is the 3rd latest full backup.
INFO: backup "2020-12-20 23:02:07" should be kept
DETAIL: This is taken after "2020-10-21 00:00:00".
WARNING: backup "2020-12-20 23:01:58" is not taken int account
DETAIL: This is not valid backup.
INFO: backup "2020-12-20 22:56:05" should be kept
DETAIL: This is taken after "2020-10-21 00:00:00".
WARNING: backup "2020-12-20 22:55:57" is not taken int account
DETAIL: This is not valid backup.
INFO: backup "2020-12-20 22:51:24" should be kept
DETAIL: This is taken after "2020-10-21 00:00:00".
INFO: backup "2020-12-20 22:41:40" should be kept
DETAIL: This is taken after "2020-10-21 00:00:00".
INFO: backup "2020-12-20 22:39:35" should be kept
DETAIL: This is taken after "2020-10-21 00:00:00".
[postgres@node_206 /postgresql/pgsql]$pg_rman validate -B /postgresql/pgsql/pg_rman_backups
INFO: validate: "2020-12-20 23:10:12" backup and archive log files by CRC
INFO: backup "2020-12-20 23:10:12" is valid
[postgres@node_206 /postgresql/pgsql]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/ detail
======================================================================================================================
 StartTime      EndTime       Mode  Data ArcLog SrvLog  Total Compressed CurTLI ParentTLI Status
======================================================================================================================
2020-12-20 23:10:12 2020-12-20 23:10:14 FULL  46MB  33MB  ---- 5520kB    true   13     12 OK
2020-12-20 23:09:48 2020-12-20 23:09:50 FULL  46MB  33MB  ---- 5507kB    true   13     12 OK
2020-12-20 23:08:23 2020-12-20 23:08:25 FULL  46MB  33MB  ---- 5495kB    true   13     12 OK
2020-12-20 23:06:51 2020-12-20 23:06:53 INCR 2465kB  33MB  ----  112kB    true   13     12 OK
2020-12-20 23:04:19 2020-12-20 23:04:25 FULL  45MB  352MB  ----  19MB    true   13     12 OK
2020-12-20 23:02:07 2020-12-20 23:02:13 FULL  82MB  301MB  ----  23MB    true   12     11 OK
2020-12-20 23:01:58 2020-12-20 23:01:58 INCR   0B  ----  ----   0B    true   12     11 ERROR
2020-12-20 22:56:05 2020-12-20 22:56:09 FULL  45MB  201MB  ---- 6251kB    true   12     11 OK
2020-12-20 22:55:57 2020-12-20 22:55:57 FULL  ----  ----  ----   0B    true    0     0 ERROR
2020-12-20 22:51:24 2020-12-20 22:51:27 FULL  45MB  117MB  ---- 6184kB    true   11     10 OK
2020-12-20 22:41:40 2020-12-20 22:41:43 INCR 1237kB  33MB  ----  390kB    true   10     0 OK
2020-12-20 22:39:35 2020-12-20 22:39:37 FULL  44MB  33MB  ---- 5451kB    true   10     0 OK
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$psql -d test
psql (12.3)
Type "help" for help.
test=# create table test5(like test);
ERROR: relation "test5" already exists
test=# create table test6(like test);
CREATE TABLE
test=# insert into test6 select * from test;
INSERT 0 2000
test=# \q
[postgres@node_206 /postgresql/pgsql]$pg_rman backup -bi -B /postgresql/pgsql/pg_rman_backups
INFO: copying database files
INFO: copying archived WAL files
INFO: backup complete
INFO: Please execute 'pg_rman validate' to verify the files are correctly copied.
INFO: start deleting old archived WAL files from ARCLOG_PATH (keep days = 10)
INFO: the threshold timestamp calculated by keep days is "2020-12-10 00:00:00"
INFO: start deleting old backup (keep generations = 3 AND keep after = 2020-10-21 00:00:00)
INFO: does not include the backup just taken
INFO: backup "2020-12-20 23:10:12" should be kept
DETAIL: This is the 1st latest full backup.
INFO: backup "2020-12-20 23:09:48" should be kept
DETAIL: This is the 2nd latest full backup.
INFO: backup "2020-12-20 23:08:23" should be kept
DETAIL: This is the 3rd latest full backup.
INFO: backup "2020-12-20 23:06:51" should be kept
DETAIL: This is taken after "2020-10-21 00:00:00".
INFO: backup "2020-12-20 23:04:19" should be kept
DETAIL: This is taken after "2020-10-21 00:00:00".
INFO: backup "2020-12-20 23:02:07" should be kept
DETAIL: This is taken after "2020-10-21 00:00:00".
WARNING: backup "2020-12-20 23:01:58" is not taken int account
DETAIL: This is not valid backup.
INFO: backup "2020-12-20 22:56:05" should be kept
DETAIL: This is taken after "2020-10-21 00:00:00".
WARNING: backup "2020-12-20 22:55:57" is not taken int account
DETAIL: This is not valid backup.
INFO: backup "2020-12-20 22:51:24" should be kept
DETAIL: This is taken after "2020-10-21 00:00:00".
INFO: backup "2020-12-20 22:41:40" should be kept
DETAIL: This is taken after "2020-10-21 00:00:00".
INFO: backup "2020-12-20 22:39:35" should be kept
DETAIL: This is taken after "2020-10-21 00:00:00".
[postgres@node_206 /postgresql/pgsql]$pg_rman validate -B /postgresql/pgsql/pg_rman_backups
INFO: validate: "2020-12-20 23:12:23" backup and archive log files by CRC
INFO: backup "2020-12-20 23:12:23" is valid
[postgres@node_206 /postgresql/pgsql]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/ detail
======================================================================================================================
 StartTime      EndTime       Mode  Data ArcLog SrvLog  Total Compressed CurTLI ParentTLI Status
======================================================================================================================
2020-12-20 23:12:23 2020-12-20 23:12:25 INCR 2621kB  33MB  ----  140kB    true   13     12 OK
2020-12-20 23:10:12 2020-12-20 23:10:14 FULL  46MB  33MB  ---- 5520kB    true   13     12 OK
2020-12-20 23:09:48 2020-12-20 23:09:50 FULL  46MB  33MB  ---- 5507kB    true   13     12 OK
2020-12-20 23:08:23 2020-12-20 23:08:25 FULL  46MB  33MB  ---- 5495kB    true   13     12 OK
2020-12-20 23:06:51 2020-12-20 23:06:53 INCR 2465kB  33MB  ----  112kB    true   13     12 OK
2020-12-20 23:04:19 2020-12-20 23:04:25 FULL  45MB  352MB  ----  19MB    true   13     12 OK
2020-12-20 23:02:07 2020-12-20 23:02:13 FULL  82MB  301MB  ----  23MB    true   12     11 OK
2020-12-20 23:01:58 2020-12-20 23:01:58 INCR   0B  ----  ----   0B    true   12     11 ERROR
2020-12-20 22:56:05 2020-12-20 22:56:09 FULL  45MB  201MB  ---- 6251kB    true   12     11 OK
2020-12-20 22:55:57 2020-12-20 22:55:57 FULL  ----  ----  ----   0B    true    0     0 ERROR
2020-12-20 22:51:24 2020-12-20 22:51:27 FULL  45MB  117MB  ---- 6184kB    true   11     10 OK
2020-12-20 22:41:40 2020-12-20 22:41:43 INCR 1237kB  33MB  ----  390kB    true   10     0 OK
2020-12-20 22:39:35 2020-12-20 22:39:37 FULL  44MB  33MB  ---- 5451kB    true   10     0 OK
[postgres@node_206 /postgresql/pgsql]$
[postgres@node_206 /postgresql/pgsql]$psql -d test
psql (12.3)
Type "help" for help.
test=# create table test7(like test);
CREATE TABLE
test=# insert into test7 select * from test;
INSERT 0 2000
test=# \q
[postgres@node_206 /postgresql/pgsql]$pg_rman backup -bf -B /postgresql/pgsql/pg_rman_backups
INFO: copying database files
INFO: copying archived WAL files
INFO: backup complete
INFO: Please execute 'pg_rman validate' to verify the files are correctly copied.
INFO: start deleting old archived WAL files from ARCLOG_PATH (keep days = 10)
INFO: the threshold timestamp calculated by keep days is "2020-12-10 00:00:00"
INFO: start deleting old backup (keep generations = 3 AND keep after = 2020-10-21 00:00:00)
INFO: does not include the backup just taken
INFO: backup "2020-12-20 23:12:23" should be kept
DETAIL: This belongs to the 1st latest full backup.
INFO: backup "2020-12-20 23:10:12" should be kept
DETAIL: This is the 1st latest full backup.
INFO: backup "2020-12-20 23:09:48" should be kept
DETAIL: This is the 2nd latest full backup.
INFO: backup "2020-12-20 23:08:23" should be kept
DETAIL: This is the 3rd latest full backup.
INFO: backup "2020-12-20 23:06:51" should be kept
DETAIL: This is taken after "2020-10-21 00:00:00".
INFO: backup "2020-12-20 23:04:19" should be kept
DETAIL: This is taken after "2020-10-21 00:00:00".
INFO: backup "2020-12-20 23:02:07" should be kept
DETAIL: This is taken after "2020-10-21 00:00:00".
WARNING: backup "2020-12-20 23:01:58" is not taken int account
DETAIL: This is not valid backup.
INFO: backup "2020-12-20 22:56:05" should be kept
DETAIL: This is taken after "2020-10-21 00:00:00".
WARNING: backup "2020-12-20 22:55:57" is not taken int account
DETAIL: This is not valid backup.
INFO: backup "2020-12-20 22:51:24" should be kept
DETAIL: This is taken after "2020-10-21 00:00:00".
INFO: backup "2020-12-20 22:41:40" should be kept
DETAIL: This is taken after "2020-10-21 00:00:00".
INFO: backup "2020-12-20 22:39:35" should be kept
DETAIL: This is taken after "2020-10-21 00:00:00".
[postgres@node_206 /postgresql/pgsql]$pg_rman validate -B /postgresql/pgsql/pg_rman_backups
INFO: validate: "2020-12-20 23:12:47" backup and archive log files by CRC
INFO: backup "2020-12-20 23:12:47" is valid
[postgres@node_206 /postgresql/pgsql]$pg_rman show -B /postgresql/pgsql/pg_rman_backups/ detail
======================================================================================================================
 StartTime      EndTime       Mode  Data ArcLog SrvLog  Total Compressed CurTLI ParentTLI Status
======================================================================================================================
2020-12-20 23:12:47 2020-12-20 23:12:50 FULL  46MB  33MB  ---- 5546kB    true   13     12 OK
2020-12-20 23:12:23 2020-12-20 23:12:25 INCR 2621kB  33MB  ----  140kB    true   13     12 OK
2020-12-20 23:10:12 2020-12-20 23:10:14 FULL  46MB  33MB  ---- 5520kB    true   13     12 OK
2020-12-20 23:09:48 2020-12-20 23:09:50 FULL  46MB  33MB  ---- 5507kB    true   13     12 OK
2020-12-20 23:08:23 2020-12-20 23:08:25 FULL  46MB  33MB  ---- 5495kB    true   13     12 OK
2020-12-20 23:06:51 2020-12-20 23:06:53 INCR 2465kB  33MB  ----  112kB    true   13     12 OK
2020-12-20 23:04:19 2020-12-20 23:04:25 FULL  45MB  352MB  ----  19MB    true   13     12 OK

总结

在 基于时间点恢复时, 如果之前做过恢复,那么此时DB与之前的备份已经不在同一时间线上。恢复默认只沿着基础备份建立时时间线恢复而不会切换到新的时间线,如果不做处理,恢复结果将和前面的完整恢复一模一样,恢复不出新插入的数据, 所以建议在恢复之后,可以接着做一个全库的备份

恢复之后, 数据库可能处于 read-only状态,此时可以用超户执行select pg_wal_replay_resume(); 或者在启动数据库实例前在postgresql.conf中添加recovery_target_action=‘promote'

pg_rman init 之后会生产 pg_rman.ini文件, 此时可以编辑该文件并添加备份策略,

我们以一个例子来说明:总共保留两周的数据,即14天的数据,每周进行一次全备,每周一和周三的2:00做一次增量备份,每天进行一次归档备份,这样我们需要对pg_rman.init中做如下配置:

?
1
2
3
4
KEEP_DATA_GENERATIONS=2
KEEP_DATA_DAYS=14
KEEP_ARCLOG_DAYS=15
KEEP_SRVLOG_DAYS=180

因为我们需要两个全备份,所以KEEP_DATA_GENERATIONS=2

两周的数据所以KEEP_DATA_DAYS=14,而可以把WAL日志多保留一天,所以KEEP_ARCLOG_DAYS=15

至少保留1000个WAL文件,每个WAL为16M,所以大约16G,占用空间不算大。

KEEP_SRVLOG_DAYS=180,通常程序日志不太,所以保留180天的日志,即3个月。

建议备份时添加参数 -C -Z

建议恢复时添加参数–hard-copy

如果没有指定这个参数,pg_rman实际上是把在归档目录中建一个软链接 指向恢复中要用到的WAL日志文件。如果指定了这个参数,则执行真的拷贝。

过程中遇到的问题

Linux 系统时间与 PG 中的时间不一致

解决方法:

?
1
2
rm -f /etc/localtime
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

以上为个人经验,希望能给大家一个参考,也希望大家多多支持服务器之家。如有错误或未考虑完全的地方,望不吝赐教。

原文链接:https://yueludanfeng.blog.csdn.net/article/details/111147141