Backup/Restore a dockerized PostgreSQL database

后端 未结 10 1963
[愿得一人]
[愿得一人] 2020-12-22 15:50

I\'m trying to backup/restore a PostgreSQL database as is explained on the Docker website, but the data is not restored.

The volumes used by the database image are:<

10条回答
  •  北荒
    北荒 (楼主)
    2020-12-22 16:13

    This is the command worked for me.

    cat your_dump.sql | sudo docker exec -i {docker-postgres-container} psql -U {user} -d {database_name}
    

    for example

    cat table_backup.sql | docker exec -i 03b366004090 psql -U postgres -d postgres
    

    Reference: Solution given by GMartinez-Sisti in this discussion. https://gist.github.com/gilyes/525cc0f471aafae18c3857c27519fc4b

提交回复
热议问题