Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/silinternational/postgresql-backup-restore-fs
Backup and/or restore a PostgreSQL database to/from a local filesystem directory
https://github.com/silinternational/postgresql-backup-restore-fs
Last synced: about 1 month ago
JSON representation
Backup and/or restore a PostgreSQL database to/from a local filesystem directory
- Host: GitHub
- URL: https://github.com/silinternational/postgresql-backup-restore-fs
- Owner: silinternational
- License: mit
- Created: 2022-06-15T15:25:54.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-20T18:23:25.000Z (4 months ago)
- Last Synced: 2024-08-21T17:03:45.237Z (4 months ago)
- Language: Shell
- Size: 131 KB
- Stars: 0
- Watchers: 5
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# postgresql-backup-restore-fs
Service to backup and/or restore a PostgreSQL database to/from a local filesystem directory## How to use it
1. Create a directory on the filesystem to hold your backups
2. Supply all appropriate environment variables
3. Run a backup and check your directory for that backup### Environment variables
`MODE` Valid values: `backup`, `restore``DB_HOST` hostname of the database server
`DB_NAME` name of the database
`DB_OPTIONS` optional arguments to supply to the backup or restore commands
`DB_ROOTPASSWORD` password for the `DB_ROOTUSER`
`DB_ROOTUSER` database administrative user, typically "postgres" for PostgreSQL databases
`DB_USERPASSWORD` password for the `DB_USER`
`DB_USER` user that accesses the database (PostgreSQL "role")
`BACKUP_DIR` e.g., _/path/to/database-backups_ **NOTE: no trailing slash**
>**Versioning of the backup file is left as an exercise for the user. This script will overwrite an existing backup file.**
## Docker Hub
This image is built automatically on Docker Hub as [silintl/postgresql-backup-restore-fs](https://hub.docker.com/r/silintl/postgresql-backup-restore-fs/)## Playing with it locally
You'll need [Docker](https://www.docker.com/get-docker), [Docker Compose](https://docs.docker.com/compose/install/), and [Make](https://www.gnu.org/software/make/).1. cd .../postgres-backup-restore-fs
2. mkdir ./mybackups
3. cp -p test/world.sql.gz ./mybackups
4. `make db` # creates the Postgres DB server
5. `make restore` # restores the DB dump file
6. `docker ps -a` # get the Container ID of the exited restore container
7. `docker logs ` # review the restoration log messages
8. `make backup` # create a new DB dump file
9. `docker ps -a` # get the Container ID of the exited backup container
10. `docker logs ` # review the backup log messages
11. `make restore` # restore the DB dump file from the new backup
12. `docker ps -a` # get the Container ID of the exited restore container
13. `docker logs ` # review the restoration log messages
14. `make clean` # remove containers and network
15. `docker volume ls` # find the volume ID of the Postgres data container
16. `docker volume rm ` # remove the data volume
17. `docker images` # list existing images
18. `docker image rm ` # remove images no longer needed