File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed
Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -28,12 +28,13 @@ func PostgreSQL(
2828 // - https://pgbackrest.org/user-guide.html#quickstart/configure-archiving
2929 // - https://pgbackrest.org/command.html#command-archive-push
3030 // - https://www.postgresql.org/docs/current/runtime-config-wal.html
31- fixTimezone := `sed -E 's/([0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{6}) (UTC|[\+\-][0-9]{2})/\1\2/' | sed 's/UTC/Z/'`
32- extractCommitTime := `awk '{print $(NF-2) "T" $(NF-1) " " $(NF)}' | ` + fixTimezone + ``
33- validateCommitTime := `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}`
31+
32+ fixTimezone := `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/" | sed "s/UTC/Z/"`
33+ extractCommitTime := `grep -oP "COMMIT \K[^;]+" | ` + fixTimezone + ``
34+ validateCommitTime := `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})$"`
3435 archive := `pgbackrest --stanza=` + DefaultStanzaName + ` archive-push "%p"`
35- archive += ` && timestamp=$(pg_waldump "%p" | grep COMMIT | ` + extractCommitTime + ` | tail -n 1 | ` + validateCommitTime + `)$' );`
36- archive += ` if [ ! -z ${timestamp} ]; then echo ${timestamp} > /pgdata/latest_commit_timestamp.txt; fi`
36+ archive += ` && timestamp=$(pg_waldump "%p" | ` + extractCommitTime + ` | tail -n 1 | ` + validateCommitTime + `);`
37+ archive += ` if [ ! -z ${timestamp} ]; then echo ${timestamp} > /pgdata/latest_commit_timestamp.txt; else echo "failed" > /pgdata/commit_ts_error.txt; fi`
3738
3839 outParameters .Mandatory .Add ("archive_mode" , "on" )
3940 outParameters .Mandatory .Add ("archive_command" , archive )
You can’t perform that action at this time.
0 commit comments