update postgres backup process
This commit is contained in:
parent
5d412184a8
commit
aded939a5d
33
postgres.md
33
postgres.md
@ -71,7 +71,7 @@ changed since the first backup.
|
||||
|
||||
- to enable WAL archiving:
|
||||
|
||||
1. set `wal_level` to `archive` (or `hot_standby`)
|
||||
1. set `wal_level` to `replica` or higher
|
||||
1. set `archive_mode` to `on`
|
||||
1. set `archive_command` to the command to use to backup
|
||||
|
||||
@ -101,34 +101,11 @@ changed since the first backup.
|
||||
|
||||
1. make a base backup
|
||||
|
||||
### make a base backup
|
||||
### make a base backup[^pg_basebackup]
|
||||
|
||||
1. ensure WAL archiving is enabled and working
|
||||
2. issue the following command as superuser:
|
||||
1. ensure that WAL archiving is working and set up properly.
|
||||
1. Run `pg_basebackup -D - -F tar > backup.tar`
|
||||
|
||||
```
|
||||
SELECT pg_start_backup('label');
|
||||
```
|
||||
|
||||
- `label` is any string to uniquely identify backup operation, e.g. the full path where you
|
||||
intend to put the backup dump file
|
||||
- It does not matter which database within the cluster you connect to to issue this command
|
||||
3. Perform the backup, using any convenient file-system-backup tool such as tar or cpio
|
||||
(not pg_dump or pg_dumpall). It is neither necessary nor desirable to stop normal operation of
|
||||
the database while you do this.
|
||||
4. issue the following command as superuser:
|
||||
|
||||
```
|
||||
SELECT pg_stop_backup();
|
||||
```
|
||||
|
||||
this terminates the backup mode and performs an automatic switch to the next WAL segment
|
||||
|
||||
|
||||
> You can also use the pg_basebackup tool to take the backup, instead of manually copying the files.
|
||||
This tool will do the equivalent of pg_start_backup(), copy and pg_stop_backup() steps
|
||||
automatically, and transfers the backup over a regular PostgreSQL connection using the replication
|
||||
protocol, instead of requiring file system level access. pg_basebackup does not interfere with
|
||||
file system level backups taken using pg_start_backup()/pg_stop_backup().
|
||||
|
||||
[^c24]: https://www.postgresql.org/docs/9.1/backup-dump.html
|
||||
[^pg_basebackup]: https://www.postgresql.org/docs/13/app-pgbasebackup.html
|
||||
|
Loading…
Reference in New Issue
Block a user