https://github.com/bfren/docker-postgresql
Docker PostgreSQL image with automatic backups.
https://github.com/bfren/docker-postgresql
backup docker docker-postgresql postgresql postgresql-server
Last synced: 5 months ago
JSON representation
Docker PostgreSQL image with automatic backups.
- Host: GitHub
- URL: https://github.com/bfren/docker-postgresql
- Owner: bfren
- License: mit
- Created: 2021-10-11T07:35:53.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-09-13T08:28:38.000Z (9 months ago)
- Last Synced: 2024-10-12T02:51:50.425Z (8 months ago)
- Topics: backup, docker, docker-postgresql, postgresql, postgresql-server
- Language: Nushell
- Homepage:
- Size: 214 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Docker PostgreSQL
   
[Docker Repository](https://hub.docker.com/r/bfren/postgresql) - [bfren ecosystem](https://github.com/bfren/docker)
[PostgreSQL](https://www.postgresql.org/) comes pre-installed (12, 13, 14, 15 or 16) with automatic backups built-in.
## Contents
* [Automatic Backups](#automatic-backups)
* [Ports](#ports)
* [Volumes](#volumes)
* [Environment Variables](#environment-variables)
* [Helper Functions](#helper-functions)
* [Licence / Copyright](#licence)## Automatic Backups
Backups for every database are stored:
* in the `/backup` volume
* in subfolders by date and time (yyMMddhhmm)
* every eight hoursSee [For Backups](#for-backups) for configuration variables.
## Ports
* 5432
## Volumes
| Volume | Purpose |
| --------- | ------------------------------------------------------------------------------------------------- |
| `/backup` | Backup files (also used for export / import scripts - see [helper functions](#helper-functions)). |
| `/data` | Data files. |## Environment Variables
### For Backups
| Variable | Values | Description | Default |
| ----------------------------- | ------------------------------------------------------------------------- | ----------------------------------------------------- | --------- |
| `BF_PG_BACKUP_COMPRESS_FILES` | 0 or 1 | Whether or not to compress backup files (using bzip). | 0 |
| `BF_PG_BACKUP_KEEP_FOR` | [Nu duration](https://www.nushell.sh/book/types_of_data.html#durations) | The length of time to keep backups. | 28day |### For Database
| Variable | Values | Description | Default |
| --------------------- | ------ | ---------------------------------------------------------------------------------------------------------------- | --------- |
| `BF_PG_APPLICATION` | string | Application name - will be used as `BF_PG_DATABASE`, `BF_PG_PASSWORD` and `BF_PG_USERNAME` if they are not set. | *None* |
| `BF_PG_DATABASE` | string | Database name(s) - multiple databases can be separated by a comma. | *None* |
| `BF_PG_PASSWORD` | string | Application password - required if `BF_PG_APPLICATION` is not | *None* |
| `BF_PG_USERNAME` | string | Application username - required if `BF_PG_APPLICATION` is not used. | *None* |## Helper Functions
| Function | Arguments | Purpose | Usage |
| ------------- | ----------------- | ------------------------------------------------------------------------------------- | ----------------------------------------------------- |
| `pg-dump` | *None* | Run backup manually. | `docker exec <> pg-dump` |
| `pg-export` | 1: Database name | Dumps the specified database as a SQL file to the root of the `/backup` volume. | `docker exec <> pg-export <>` |
| `pg-import` | 1: Database name | Executes all files in the root of the `/backup` volume. | `docker exec <> pg-import <>` |
| `pg-restore` | 1: Backup set | Deletes all files in `/data` volume, then restores from the specified backup dump. | `docker exec <> pg-restore 202107180500` |## Licence
> [MIT](https://mit.bfren.dev/2021)
## Copyright
> Copyright (c) 2021-2024 [bfren](https://bfren.dev) (unless otherwise stated)