Docker images for postgres extended with management bash scripts.
at main 68 lines 1.5 kB view raw view rendered
1# Extended PostgreSQL Docker Image 2 3Docker image for `postgres` extended with management bash scripts. 4 5## Build images 6 7To build the images and push them to the registry: 8 9 make build 10 make push 11 12## Docker-compose example 13 14Example of a `docker-compose.yml` file that uses this image: 15 16```yaml 17 version: '3' 18 19 volumes: 20 postgres_data: {} 21 postgres_backups: {} 22 23 services: 24 25 service: 26 image: service:latest 27 command: ./start 28 29 postgres: 30 image: marcosgabarda/postgres:latest 31 volumes: 32 - postgres_data:/var/lib/postgresql/data 33 - postgres_backups:/backups 34 env_file: 35 - ./.env 36``` 37 38## Maintenance commands 39 40This images adds commands to the original PostgreSQL image for maintenance proposes. 41 42### Create a database backup 43 44Creates a backup of the database. Usage: 45 46 $ docker compose -f <environment>.yml (exec |run --rm) postgres backup 47 48### View backups 49 50Views a list of all created backups of the database. Usage: 51 52 $ docker compose -f <environment>.yml (exec |run --rm) postgres backups 53 54### Creates a read only user 55 56Creates a read only user. Usage: 57 58 $ docker compose -f <environment>.yml (exec |run --rm) postgres createreaduser 59 60### Restore database from a backup 61 62Restores the indicated database backup. Usage: 63 64 $ docker compose -f <environment>.yml (exec |run --rm) postgres restore <1> 65 66Parameters: 67 68 * `<1>` filename of an existing backup.