How to generate a Postgresql Dump from a Docker container?

前端 未结 5 603
忘掉有多难
忘掉有多难 2021-01-31 02:55

I would like to have a way to enter into the Postgresql container and get a data dump from it.

5条回答
  •  闹比i
    闹比i (楼主)
    2021-01-31 03:43

    I have container named postgres with mounted volume -v /backups:/backups

    To backup gziped DB my_db I use:

    docker exec postgres pg_dump -U postgres -F t my_db | gzip >/backups/my_db-$(date +%Y-%m-%d).tar.gz
    

    Now I have

    user@my-server:/backups$ ls
    my_db-2016-11-30.tar.gz
    

提交回复
热议问题