Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker Deployment #2

Open
laportem opened this issue Jul 30, 2021 · 6 comments
Open

Docker Deployment #2

laportem opened this issue Jul 30, 2021 · 6 comments
Labels
question Further information is requested

Comments

@laportem
Copy link

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

@8byr0
Copy link
Owner

8byr0 commented Jul 30, 2021

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.

@8byr0 8byr0 added the question Further information is requested label Jul 30, 2021
@8byr0
Copy link
Owner

8byr0 commented Aug 1, 2021

@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.

@laportem
Copy link
Author

laportem commented Aug 2, 2021

thanks, will give it a try and feedback if issues

@laportem
Copy link
Author

laportem commented Aug 4, 2021

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

@anirudhmurali
Copy link

Could you guide on the same for restoring from dump for docker setup?

@8byr0
Copy link
Owner

8byr0 commented Dec 28, 2021

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 :

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants