wal 아카이빙
## wal-g download
root@primary:/root# wget https://github.com/wal-g/wal-g/releases/download/v0.2.19/wal-g.linux-amd64.tar.gz
root@primary:/root# tar -zxvf wal-g.linux-amd64.tar.gz
wal-g
root@primary:/root# mv wal-g /mnt/pgsql/12/bin/
root@primary:/root# chmod 755 /mnt/pgsql/12/bin/wal-g
## PATH설정
POSTGRES_HOME=/mnt/pgsql/12
PATH=$POSTGRES_HOME/bin:$PATH
##아카이브를 저장할 디렉토리 생성
root@primary:/mnt/pgsql/12/data# mkdir /pg_archive
root@primary:/mnt/pgsql/12/data# chown postgres.postgres /pg_archive/
## postgressql.conf 수정
root@primary:/root# vi /mnt/pgsql/12/data/postgresql.conf
listen_addresses = '*'
wal_level = logical
archive_mode = on
archive_command = 'WALG_FILE_PREFIX=/pg_archive /mnt/pgsql/12/bin/wal-g wal-push %p'
archive_timeout = 60
%p : WAL 로그파일 절대경로
%f : 보관할 로그 파일 이름
## config reload
postgres@primary:/home/postgres# /usr/pgsql-12/bin/pg_ctl reload -D /mnt/pgsql/12/data/
확인
postgres=# show archive_command;
archive_command
------------------------------------------------------------------
WALG_FILE_PREFIX=/pg_archive /mnt/pgsql/12/bin/wal-g wal-push %p
(1 row)
## Backup test
postgres@primary:/home/postgres# WALG_FILE_PREFIX=/pg_archive/ wal-g backup-push /mnt/pgsql/12/data/
INFO: 2021/11/25 12:04:03.412766 Doing full backup.
INFO: 2021/11/25 12:04:03.502371 Calling pg_start_backup()
INFO: 2021/11/25 12:04:03.728601 Walking ...
INFO: 2021/11/25 12:04:03.728870 Starting part 1 ...
INFO: 2021/11/25 12:04:06.796144 Finished writing part 1.
INFO: 2021/11/25 12:04:06.796168 Starting part 2 ...
INFO: 2021/11/25 12:04:06.796177 /global/pg_control
INFO: 2021/11/25 12:04:06.797188 Finished writing part 2.
INFO: 2021/11/25 12:04:06.797908 Calling pg_stop_backup()
INFO: 2021/11/25 12:04:07.818743 Starting part 3 ...
INFO: 2021/11/25 12:04:07.822203 backup_label
INFO: 2021/11/25 12:04:07.822371 tablespace_map
INFO: 2021/11/25 12:04:07.822534 Finished writing part 3.
INFO: 2021/11/25 12:04:07.832987 Wrote backup with name base_00000007000000000000003F
## Backup 확인
postgres@primary:/home/postgres# WALG_FILE_PREFIX=/pg_archive/ wal-g wal-show
+-----+------------+-----------------+--------------------------+--------------------------+---------------+----------------+--------+---------------+
| TLI | PARENT TLI | SWITCHPOINT LSN | START SEGMENT | END SEGMENT | SEGMENT RANGE | SEGMENTS COUNT | STATUS | BACKUPS COUNT |
+-----+------------+-----------------+--------------------------+--------------------------+---------------+----------------+--------+---------------+
| 7 | 0 | 0 | 000000070000000000000032 | 00000007000000000000003F | 14 | 14 | OK | 1 |
+-----+------------+-----------------+--------------------------+--------------------------+---------------+----------------+--------+---------------+
postgres@primary:/home/postgres# WALG_FILE_PREFIX=/pg_archive/ wal-g wal-verify
INFO: 2021/11/25 12:05:30.316597 Detected earliest available backup: base_00000007000000000000003F
+-----+--------------------------+--------------------------+----------------+--------+
| TLI | START | END | SEGMENTS COUNT | STATUS |
+-----+--------------------------+--------------------------+----------------+--------+
| 7 | 00000007000000000000003F | 000000070000000000000040 | 2 | FOUND |
+-----+--------------------------+--------------------------+----------------+--------+
WAL storage status: OK
## backup list확인
postgres@primary:/home/postgres# WALG_FILE_PREFIX=/pg_archive/ wal-g backup-list
name last_modified wal_segment_backup_start
base_00000007000000000000003F 2021-11-25T12:04:07+09:00 00000007000000000000003F
다음 글에서 back & recovery 테스트를 하겠습니다.
참고
https://chowdera.com/2021/01/20210101080911469e.html
PG 13 wal-g local directory backup and recovery - 文章整合
One 、 Secure backup configuration 1. System package -# more /etc/redhat-release CentOS Linux release 7.4.1708 (Core) -# 1).install postgresql -# yum install gcc-c++ readline-devel zlib-devel -# tar zxvf postgresql-13.1.tar.gz -# cd postgresql-13.1 -# ./c
chowdera.com
https://supabase.com/blog/2020/08/02/continuous-postgresql-backup-walg
Continuous PostgreSQL Backups using WAL-G
Have you ever wanted to restore your database's state to a particular moment in time? This post explains how, using WAL-G.
supabase.com
'DataBase > PostgreSQL' 카테고리의 다른 글
[PostgreSQL - PGDUMP 백업&복구] (0) | 2022.03.24 |
---|---|
[PostgreSQL - Wal-g 백업 & 복구] part 2 (0) | 2022.03.24 |
[PostgreSQL - Repmgr구성 + PGPOOL&PGBOUNCER] part2 (0) | 2022.01.29 |
[PostgreSQL - Repmgr 구성 & Failover test] part 1 (0) | 2022.01.20 |
[PostgreSQL - 12.3 install] (0) | 2022.01.20 |