i have postgresql database in docker container with id d41acda53547 there is database…
- User
i have postgresql database in docker container with id d41acda53547
there is database named db1, i want to make pg_dump, and save it to /hdd directory. but the database is rather big, so i want to compress while dumping. how to do this from cli?
- Assistant
To perform a
pg_dumpof a PostgreSQL database and compress it on-the-fly using Docker, you can use the command line to execute the necessary commands inside the Docker container. Here's how you can do it:-
Run
pg_dumpinside the Docker container and compress the output usinggzip. You can achieve this by using Docker'sexeccommand to execute the dump inside the container. The following command illustrates how you can do this:docker exec d41acda53547 pg_dump -U <username> db1 | gzip > /hdd/db1_backup.sql.gz- Replace with your PostgreSQL user name.
-