@@ -22,14 +22,14 @@ func TestPostgreSQLParameters(t *testing.T) {
22
22
assert .DeepEqual (t , parameters .Mandatory .AsMap (), map [string ]string {
23
23
"archive_mode" : "on" ,
24
24
"archive_command" : strings .Join ([]string {
25
- `pgbackrest --stanza=db archive-push "%p"` ,
26
- ` && timestamp=$(pg_waldump "%p" | grep COMMIT | awk '{print $(NF ` ,
27
- `-2) "T" $(NF-1) " " $(NF)}' | sed -E 's/([0-9]{4}-[0-9]{2}-[0-9] ` ,
28
- `{2}T [0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{6}) (UTC|[\+\ -][0-9]{2})/\` ,
29
- `1\2/' | sed ' s/UTC/Z/' | tail -n 1 | grep -E '^[0-9]{4}-[0-9]{2} ` ,
30
- `-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{6}(Z|[\+\-][0-9]{2})` ,
31
- "$'); if [ ! -z ${timestamp} ]; then echo ${timestamp} > /pgdata/l" ,
32
- "atest_commit_timestamp .txt; fi" ,
25
+ `pgbackrest --stanza=db archive-push "%p" ` ,
26
+ `&& timestamp=$(pg_waldump "%p" | ` ,
27
+ `grep -oP "COMMIT \K[^;]+" | ` ,
28
+ `sed -E "s/([0-9]{4}-[0-9]{2}- [0-9]{2}) ([0-9]{2} :[0-9]{2}:[0-9]{2}\.[0-9]{6}) (UTC|[\\+\\ -][0-9]{2})/\1T\2\3/" | ` ,
29
+ `sed " s/UTC/Z/" | ` ,
30
+ "tail -n 1 | " ,
31
+ `grep -E "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{6}(Z|[\+\-][0-9]{2})$"); ` ,
32
+ "if [ ! -z ${timestamp} ]; then echo ${timestamp} > /pgdata/latest_commit_timestamp .txt; fi" ,
33
33
}, "" ),
34
34
"restore_command" : `pgbackrest --stanza=db archive-get %f "%p"` ,
35
35
"track_commit_timestamp" : "true" ,
@@ -48,14 +48,14 @@ func TestPostgreSQLParameters(t *testing.T) {
48
48
assert .DeepEqual (t , parameters .Mandatory .AsMap (), map [string ]string {
49
49
"archive_mode" : "on" ,
50
50
"archive_command" : strings .Join ([]string {
51
- `pgbackrest --stanza=db archive-push "%p"` ,
52
- ` && timestamp=$(pg_waldump "%p" | grep COMMIT | awk '{print $(NF ` ,
53
- `-2) "T" $(NF-1) " " $(NF)}' | sed -E 's/([0-9]{4}-[0-9]{2}-[0-9] ` ,
54
- `{2}T [0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{6}) (UTC|[\+\ -][0-9]{2})/\` ,
55
- `1\2/' | sed ' s/UTC/Z/' | tail -n 1 | grep -E '^[0-9]{4}-[0-9]{2} ` ,
56
- `-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{6}(Z|[\+\-][0-9]{2})` ,
57
- "$'); if [ ! -z ${timestamp} ]; then echo ${timestamp} > /pgdata/l" ,
58
- "atest_commit_timestamp .txt; fi" ,
51
+ `pgbackrest --stanza=db archive-push "%p" ` ,
52
+ `&& timestamp=$(pg_waldump "%p" | ` ,
53
+ `grep -oP "COMMIT \K[^;]+" | ` ,
54
+ `sed -E "s/([0-9]{4}-[0-9]{2}- [0-9]{2}) ([0-9]{2} :[0-9]{2}:[0-9]{2}\.[0-9]{6}) (UTC|[\\+\\ -][0-9]{2})/\1T\2\3/" | ` ,
55
+ `sed " s/UTC/Z/" | ` ,
56
+ "tail -n 1 | " ,
57
+ `grep -E "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{6}(Z|[\+\-][0-9]{2})$"); ` ,
58
+ "if [ ! -z ${timestamp} ]; then echo ${timestamp} > /pgdata/latest_commit_timestamp .txt; fi" ,
59
59
}, "" ),
60
60
"restore_command" : `pgbackrest --stanza=db archive-get %f "%p" --repo=99` ,
61
61
"track_commit_timestamp" : "true" ,
0 commit comments