Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added wal-g example to docs #726

Merged
merged 1 commit into from
Nov 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ We suggest that you first read the [Stolon Architecture and Requirements](archit
* Backup/Restore
* [Point In Time Recovery](pitr.md)
* [Point In Time Recovery with wal-e](pitr_wal-e.md)
* [Point In Time Recovery with wal-g](pitr_wal-g.md)
* [Standby Cluster](standbycluster.md)

### Misc topics
Expand Down
4 changes: 3 additions & 1 deletion doc/pitr.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
## Point in time recovery

Stolon can do a point a time recovery starting from an existing backup.
This example shows how to do point in time recovery with stolon using [wal-e](https://github.com/wal-e/wal-e)

* [This](pitr_wal-g.md) example shows how to do point in time recovery with stolon using [wal-g](https://github.com/wal-g/wal-g)
* [This](pitr_wal-e.md) example shows how to do point in time recovery with stolon using [wal-e](https://github.com/wal-e/wal-e)


### Backups
Expand Down
33 changes: 33 additions & 0 deletions doc/pitr_wal-g.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
## Point in time recovery with wal-g

[wal-g](https://github.com/wal-g/wal-g) is the successor of wal-e, which no longer seems to be in active development!
This example shows how to do point in time recovery with stolon using [wal-g](https://github.com/wal-g/wal-g)

[wal-g](https://github.com/wal-g/wal-g) correctly suggests to not put environment variables containing secret data (like aws secret keys) inside the `archive_command` since every user connected to postgres could read them. In its examples wal-g suggests to use the `envdir` command to set the wal-g required environment variables or (since some distribution don't have it) just use a custom script that sets them.

### Backups

#### Base backups

Take the base backups using the `wal-g backup-push` command.

#### Archive backups

For doing this you should set at least the `archive_mode` and the `archive_command` pgParameters in the cluster spec. Wal-g will be used as the archive command:

```
stolonctl update --patch '{ "pgParameters" : { "archive_mode": "on", "archive_command": "envdir /etc/wal-g.d/env wal-g wal-push %p" } }'
```


### Execute a point in time recovery

Note: looks like wal-g doesn't backups various config files like `postgresql.conf`, `pg_hba.conf`. While `pg_hba.conf` is currently generated by stolon, you'd like to keep the previous postgres parameters after the restore. For doing this there're two different ways:

* if you want to backup the `postgresql.conf` you should do this outside `wal-g`. To restore it you have to create a `dataRestoreCommand` that will restore it after the `wal-g backup fetch` command.
* if you don't want to backup/restore it than you can just set all the `pgParameters` inside the [cluster specification](cluster_spec.md)

```
stolonctl init '{ "initMode": "pitr", "pitrConfig": { "dataRestoreCommand": "envdir /etc/wal-g.d/env wal-g backup-fetch %d LATEST" , "archiveRecoverySettings": { "restoreCommand": "envdir /etc/wal-g.d/env wal-g wal-fetch \"%f\" \"%p\"" } } }'
```