Версия wal-g
wal-g -version
v0.1.15
Иницилизирую бд
/usr/pgsql-9.6/bin/postgresql96-setup initdb
Initializing database ... OK
стартую БД
systemctl start postgresql-9.6
postgres=# create database test1;
CREATE DATABASE
postgres=# \c test1;
You are now connected to database "test1" as user "postgres".
test1=# CREATE TABLE large_test (num1 bigint, num2 double precision, num3 double precision);
CREATE TABLE
test1=# INSERT INTO large_test (num1, num2, num3)
SELECT round(random()*10), random(), random()*142
FROM generate_series(1, 20000000) s(i);
INSERT 0 20000000
Запускаю wal-g backup-push
#!/bin/bash
. /etc/wal-g.d/server-s3.conf
wal-g backup-push /var/lib/pgsql/9.6/data/
postgres=# create database test2;
CREATE DATABASE
postgres=# \c test2;
You are now connected to database "test2" as user "postgres".
test2=# CREATE TABLE large_test (num1 bigint, num2 double precision, num3 double precision);
CREATE TABLE
test2=# INSERT INTO large_test (num1, num2, num3)
SELECT round(random()*10), random(), random()*142
FROM generate_series(1, 20000000) s(i);
INSERT 0 20000000
список файлов в папке pg_xlog после команды "create database test2;"
https://hastebin.com/ifonukifus.css
список файлов в minio в папке wal_005 в бакете pg-backups
https://hastebin.com/ifaqapacoj.css
Останавливаю Postgresql
Удаляю все из папки /var/lib/pgsql/9.6/data
потом запускаю backup_fetch_latest.sh
Содержимое backup_fetch_latest.sh
#!/bin/bash
. /etc/wal-g.d/server-s3.conf
wal-g backup-fetch /var/lib/pgsql/9.6/data LATEST
Backup extraction complete.
Добавляю recovery.conf в папку /var/lib/pgsql/9.6/data
standby_mode = 'on'
restore_command = '/usr/local/bin/wal-fetch.sh "%f" "%p"'
Содержимое wal-fetch.sh
cat /usr/local/bin/wal-fetch.sh
#!/bin/bash
. /etc/wal-g.d/server-s3.conf
wal-g wal-fetch $1 $2
systemctl start postgresql-9.6
tail -fn100 /var/lib/pgsql/9.6/data/pg_log/postgresql-Wed.log
Логи postgresql-Wed.log тут
https://hastebin.com/okosecoxel.makefile
Если поискать файл 0000000100000000000000CC, то его можно найти
locate 0000000100000000000000CC
/var/lib/pgsql/9.6/data/pg_xlog/0000000100000000000000CC
ls -lh /var/lib/pgsql/9.6/data/pg_xlog/0000000100000000000000CC
-rw------- 1 postgres postgres 16M Feb 13 11:05 /var/lib/pgsql/9.6/data/pg_xlog/0000000100000000000000CC
cat /etc/wal-g.d/server-s3.conf
#!/bin/bash
export WALE_S3_PREFIX="s3://pg-backups"
export AWS_ACCESS_KEY_ID="xxxx"
export AWS_ENDPOINT="http://10.233.60.57:9000"
export AWS_S3_FORCE_PATH_STYLE="true"
export AWS_SECRET_ACCESS_KEY="yyyy"
export PGDATA=/var/lib/pgsql/9.6/data/
export PGHOST=/var/run/postgresql/.s.PGSQL.5432
export WALG_UPLOAD_CONCURRENCY=2
export WALG_DOWNLOAD_CONCURRENCY=2
export WALG_UPLOAD_DISK_CONCURRENCY=2
export WALG_DELTA_MAX_STEPS=7