pg_restore in postgres docker container

后端 未结 2 2340
情话喂你
情话喂你 2021-02-20 18:46

I am trying to restore database in PostgreSQL docker container using pg_restore from a shellscript taht will be called from docker file .I am getting following error \"E

相关标签:
2条回答
  • 2021-02-20 19:22

    Here is a way to restore from a file located on the host machine:

    docker exec -i container_name pg_restore -U postgres_user -v -d database_name < /dir_backup_outside_container/file_name.tar
    
    0 讨论(0)
  • 2021-02-20 19:29

    I don't think the backup restore can be done during the initialization phase. Start your container and then upload the db.

    docker run -d --name mydb mypgimage
    docker exec mydb sh -c "pg_restore -C -d DB /var/lib/postgresql/backup/DB.backup"
    
    0 讨论(0)
提交回复
热议问题