postgres docker 容器中的 pg_restore [英] pg_restore in postgres docker container

查看:65
本文介绍了postgres docker 容器中的 pg_restore的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 shellscript 中的 pg_restore 恢复 PostgreSQL docker 容器中的数据库,taht 将从 docker 文件中调用.我收到以下错误 "ERROR: canceling autovacuum taskCONTEXT:自动分析表'tablename'".

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 "ERROR: canceling autovacuum task CONTEXT: automatic analyze of table 'tablename'".

DockerFile:

    FROM postgres:9.3
    ENV POSTGRES_USER postgres
    ENV POSTGRES_PASSWORD Abcd1234
    ENV POSTGRES_DB Clarion1
    COPY DB.backup /var/lib/postgresql/backup/DB.backup
    COPY initialize.sh /docker-entrypoint-initdb.d/initialize.sh

initialize.sh

    #!/bin/bash
    set -e
    set -x

    echo "******PostgreSQL initialisation******"
    pg_restore -C -d DB /var/lib/postgresql/backup/DB.backup

日志:

    server started
    CREATE DATABASE
    /docker-entrypoint.sh: running /docker-entrypoint-initdb.d/initialize.sh
    ++ echo '******PostgreSQL initialisation******'
    ++ pg_restore -C -d Clarion1 /var/lib/postgresql/backup/Clarion53.backup
    ******PostgreSQL initialisation******
    ERROR:  canceling autovacuum task

但是,如果我尝试从同一备份文件的主机中的命令提示符恢复数据库,它工作正常.

推荐答案

这是一种从位于主机上的文件恢复的方法:

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

这篇关于postgres docker 容器中的 pg_restore的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆