diff options
author | Quentin Dufour <quentin@deuxfleurs.fr> | 2022-01-27 18:26:02 +0100 |
---|---|---|
committer | Quentin Dufour <quentin@deuxfleurs.fr> | 2022-01-27 18:26:02 +0100 |
commit | 2775eeb0feb2b443cbd05f9a6c79800685441fe0 (patch) | |
tree | 80ccb06ff8dbfbe5b1471d3e432d5600e6228833 /op_guide | |
parent | 715c3d3a9fabd5531485736d6dc0ad8e47156b16 (diff) | |
download | infrastructure-2775eeb0feb2b443cbd05f9a6c79800685441fe0.tar.gz infrastructure-2775eeb0feb2b443cbd05f9a6c79800685441fe0.zip |
WIP manual backup
Diffstat (limited to 'op_guide')
-rw-r--r-- | op_guide/stolon/README.md | 3 | ||||
-rw-r--r-- | op_guide/stolon/create_database.md (renamed from op_guide/create_database/README.md) | 0 | ||||
-rw-r--r-- | op_guide/stolon/install.md (renamed from op_guide/init_stolon/README.md) | 0 | ||||
-rw-r--r-- | op_guide/stolon/manual_backup.md | 51 |
4 files changed, 54 insertions, 0 deletions
diff --git a/op_guide/stolon/README.md b/op_guide/stolon/README.md new file mode 100644 index 0000000..9e76b0e --- /dev/null +++ b/op_guide/stolon/README.md @@ -0,0 +1,3 @@ + - [Initialize the cluster](install.md) + - [Create a database](create_database.md) + - [Manually backup all the databases](manual_backup.md) diff --git a/op_guide/create_database/README.md b/op_guide/stolon/create_database.md index fb3bdd9..fb3bdd9 100644 --- a/op_guide/create_database/README.md +++ b/op_guide/stolon/create_database.md diff --git a/op_guide/init_stolon/README.md b/op_guide/stolon/install.md index b511f59..b511f59 100644 --- a/op_guide/init_stolon/README.md +++ b/op_guide/stolon/install.md diff --git a/op_guide/stolon/manual_backup.md b/op_guide/stolon/manual_backup.md new file mode 100644 index 0000000..b952174 --- /dev/null +++ b/op_guide/stolon/manual_backup.md @@ -0,0 +1,51 @@ +## Disclaimer + +Do **NOT** use the following backup methods on the Stolon Cluster: + 1. copying the data directory + 2. `pg_dump` + 3. `pg_dumpall` + +The first one will lead to corrupted/inconsistent files. +The second and third ones put too much pressure on the cluster. +Basically, you will destroy it, in the following ways: + - Load will increase, requests will timeout + - RAM will increase, the daemon will be OOM (Out Of Memory) killed by Linux + - Potentially, the WAL log will grow a lot + + +## A binary backup with `pg_basebackup` + +The only acceptable solution is `pg_basebackup` with **some throttling configured**. +Later, if you want a SQL dump, you can inject this binary backup on an ephemeral database you spawned solely for this purpose on a non-production machine. + +First, start by fetching from Consul the identifiers of the replication account. +Do not use the root account setup in Stolon, it will not work. + +First setup a SSH tunnel on your machine that bind postgresql, eg: + +```bash +ssh -L 5432:psql-proxy.service.2.cluster.deuxfleurs.fr:5432 ... +``` + +Then export your password in `PGPASSWORD` and launch the backup: + +```bash +export PGPASSWORD=xxx + +pg_basebackup \ + --host=127.0.0.1 \ + --username=replicator \ + --pgdata=/tmp/sql \ + --format=tar \ + --wal-method=none \ + --gzip \ + --compress=6 \ + --progress \ + --max-rate=2M +``` + +*Take a cup of coffe, it will take some times...* + +## Importing the backup + +## Dump SQL |