Open laportem opened 3 years ago
I actually tested postgres backup workflow using docker. All you need is the pgdump tool which is basically just a postgres client.
You can definitely have it without a whole PG install, see this thread for more : https://dba.stackexchange.com/questions/193023/pg-dump-without-postgresql
I plan to add configuration option where you would be able to give the path to pg_dump tool. With this new way you'd be able to bind directly pg_dump from postgres container using volumes.
@laportem release 0.5.1 is out with pg_dump path override.
You can now add to config/plugins.js
// config/plugins.js
module.exports = () => ({
//...
"backup-restore": {
postgres: {
// Update with your path
pathToPgDump: "/usr/local/opt/libpq/bin/pg_dump",
},
},
});
If you want to keep your strapi image as it is now, you could bind pg_dump from postgres container. See https://phoenixnap.com/kb/how-to-share-data-between-docker-containers for more. Basically it's just about binding the tool to a path in strapi container and then use this path in strapi config.
thanks, will give it a try and feedback if issues
Got the backup to work ok. i see on your TODO list, restore is still in the pipeline. Until then can you advise on a restore progress
Could you guide on the same for restoring from dump for docker setup?
Got the backup to work ok. i see on your TODO list, restore is still in the pipeline. Until then can you advise on a restore progress
Sorry for late reply, I have actually no ETA for this. If anyone wants to submit a PR feel free to do it!
Could you guide on the same for restoring from dump for docker setup? Since it's not yet implemented in this plugin you'd have to handle it manually. Using docker based install, you can achieve this using
# copy backup in your db container docker cp my_data.dump postgres_container:/backups
docker exec postgres_container pg_restore -U postgres -d some_database /backups/my_data.dump
More here:
https://simkimsia.com/how-to-restore-database-dumps-for-postgres-in-docker-container/
https://www.postgresqltutorial.com/postgresql-restore-database/
The same could be achieved for mysql, you just need to update exec command :
```shell
docker cp backup.sql postgres_container:/backups
docker exec postgres_container mysql -u [user] -p [database_name] < /backups/backup.sql
More: https://phoenixnap.com/kb/how-to-backup-restore-a-mysql-database
This assumes that Postgres is physically installed on the machine. But what if I have both Strapi and Postgres running in docker containers. How do I get the plugin to see pg_dump