为什么我的postgres数据从备份加载后消失?

我使用官方的Postgres docker镜像,我添加了一个shell脚本,在真正启动服务器之前加载备份(按照“如何扩展这个镜像”

我的负载备份脚本如下所示:

gosu postgres pg_ctl start -w -D /var/lib/postgresql/data gosu postgres psql -d postgres -f /dump/dump.sql gosu postgres pg_ctl stop -w -D /var/lib/postgresql/data 

然后Postgres映像自动调用postgres来启动服务器。

从我的日志中我知道,psql和postgres命令都运行良好,但是当我进入psql( docker exec -it CONTAINER_ID psql -U postgres ),并且我\c进入正确的数据库和\dt列出关系时,在那儿!

为什么会这样呢?

我得到了以下错误(由docker logs CONTAINER_ID | grep "^[AZ]*:\s" ),但是我不知道该怎么做。 如果某些函数或扩展不存在,这有什么关系? 在这种情况下我不使用它们:

 WARNING: enabling "trust" authentication for local connections You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb. **************************************************** WARNING: No password has been set for the database. This will allow anyone with access to the Postgres port to access your database. In Docker's default configuration, this is effectively any other container on the same system. Use "-e POSTGRES_PASSWORD=password" to set it in "docker run". **************************************************** psql:/dump/dump.sql:94: ERROR: could not open extension control file "/usr/shar e/postgresql/9.4/extension/plpython3u.control": No such file or directory psql:/dump/dump.sql:101: ERROR: extension "plpython3u" does not exist LOG: database system is ready to accept connections LOG: autovacuum launcher started ERROR: could not open extension control file "/usr/share/postgresql/9.4/extensi on/plpython3u.control": No such file or directory STATEMENT: CREATE EXTENSION IF NOT EXISTS plpython3u WITH SCHEMA pg_catalog; ERROR: extension "plpython3u" does not exist STATEMENT: COMMENT ON EXTENSION plpython3u IS 'PL/Python3U untrusted procedural language'; ERROR: language "plpython3u" does not exist psql:/dump/dump.sql:331: ERROR: language "plpython3u" does not exist HINT: Use CREATE LANGUAGE to load the language into the database. psql:/dump/dump.sql:334: ERROR: function cuffdiff_metadata.load_all_cuffdiff_me tadata(text) does not exist HINT: Use CREATE LANGUAGE to load the language into the database. STATEMENT: CREATE FUNCTION load_all_cuffdiff_metadata(rna_seq_root text) RETURN S void ERROR: function cuffdiff_metadata.load_all_cuffdiff_metadata(text) does not exi st STATEMENT: ALTER FUNCTION cuffdiff_metadata.load_all_cuffdiff_metadata(rna_seq_ root text) OWNER TO postgres; ERROR: language "plpython3u" does not exist HINT: Use CREATE LANGUAGE to load the language into the database. STATEMENT: CREATE FUNCTION filter_methylation(file_name text) RETURNS void psql:/dump/dump.sql:701: ERROR: language "plpython3u" does not exist HINT: Use CREATE LANGUAGE to load the language into the database. psql:/dump/dump.sql:704: ERROR: function methylation.filter_methylation(text) d oes not exist psql:/dump/dump.sql:897: ERROR: language "plpython3u" does not exist HINT: Use CREATE LANGUAGE to load the language into the database. psql:/dump/dump.sql:900: ERROR: function public.debug(text) does not exist ERROR: function methylation.filter_methylation(text) does not exist STATEMENT: ALTER FUNCTION methylation.filter_methylation(file_name text) OWNER TO postgres; ERROR: language "plpython3u" does not exist HINT: Use CREATE LANGUAGE to load the language into the database. STATEMENT: CREATE FUNCTION debug(msg text) RETURNS void ERROR: function public.debug(text) does not exist STATEMENT: ALTER FUNCTION public.debug(msg text) OWNER TO postgres; ERROR: language "plpython3u" does not exist HINT: Use CREATE LANGUAGE to load the language into the database. STATEMENT: CREATE FUNCTION load_all(csv_root text) RETURNS void psql:/dump/dump.sql:1015: ERROR: language "plpython3u" does not exist HINT: Use CREATE LANGUAGE to load the language into the database. ERROR: function public.load_all(text) does not exist psql:/dump/dump.sql:1018: ERROR: function public.load_all(text) does not exist psql:/dump/dump.sql:1115: ERROR: language "plpython3u" does not exist HINT: Use CREATE LANGUAGE to load the language into the database. psql:/dump/dump.sql:1118: ERROR: function rnaseq.load_all_cuffdiff(text) does n ot exist psql:/dump/dump.sql:1175: ERROR: language "plpython3u" does not exist HINT: Use CREATE LANGUAGE to load the language into the database. STATEMENT: ALTER FUNCTION public.load_all(csv_root text) OWNER TO postgres; ERROR: language "plpython3u" does not exist HINT: Use CREATE LANGUAGE to load the language into the database. STATEMENT: CREATE FUNCTION load_all_cuffdiff(cuffdiff_root text) RETURNS void ERROR: function rnaseq.load_all_cuffdiff(text) does not exist STATEMENT: ALTER FUNCTION rnaseq.load_all_cuffdiff(cuffdiff_root text) OWNER TO postgres; ERROR: language "plpython3u" does not exist HINT: Use CREATE LANGUAGE to load the language into the database. STATEMENT: CREATE FUNCTION load_all_voom_edger(rna_seq_root text) RETURNS void psql:/dump/dump.sql:1178: ERROR: function rnaseq.load_all_voom_edger(text) does not exist ERROR: function rnaseq.load_all_voom_edger(text) does not exist STATEMENT: ALTER FUNCTION rnaseq.load_all_voom_edger(rna_seq_root text) OWNER T O postgres; LOG: checkpoints are occurring too frequently (2 seconds apart) HINT: Consider increasing the configuration parameter "checkpoint_segments". LOG: checkpoints are occurring too frequently (3 seconds apart) HINT: Consider increasing the configuration parameter "checkpoint_segments". LOG: checkpoints are occurring too frequently (3 seconds apart) HINT: Consider increasing the configuration parameter "checkpoint_segments". LOG: checkpoints are occurring too frequently (2 seconds apart) HINT: Consider increasing the configuration parameter "checkpoint_segments". LOG: checkpoints are occurring too frequently (6 seconds apart) HINT: Consider increasing the configuration parameter "checkpoint_segments". LOG: sending cancel to blocking autovacuum PID 69 DETAIL: Process 68 waits for AccessExclusiveLock on relation 16459 of database 12141. STATEMENT: ALTER TABLE ONLY histone_homer ERROR: canceling autovacuum task CONTEXT: automatic analyze of table "postgres.histone.histone_homer" LOG: sending cancel to blocking autovacuum PID 69 DETAIL: Process 68 waits for AccessExclusiveLock on relation 16468 of database 12141. STATEMENT: ALTER TABLE ONLY histone_macs ERROR: canceling autovacuum task CONTEXT: automatic analyze of table "postgres.histone.histone_macs" LOG: sending cancel to blocking autovacuum PID 69 DETAIL: Process 68 waits for AccessExclusiveLock on relation 16485 of database 12141. STATEMENT: ALTER TABLE ONLY macs_gene_map ERROR: canceling autovacuum task CONTEXT: automatic analyze of table "postgres.histone.macs_gene_map" LOG: sending cancel to blocking autovacuum PID 69 DETAIL: Process 68 waits for AccessExclusiveLock on relation 16543 of database 12141. STATEMENT: ALTER TABLE ONLY cg_islands ERROR: canceling autovacuum task CONTEXT: automatic analyze of table "postgres.methylation.cg_islands" LOG: sending cancel to blocking autovacuum PID 69 DETAIL: Process 68 waits for AccessExclusiveLock on relation 16551 of database 12141. STATEMENT: ALTER TABLE ONLY methylation ERROR: canceling autovacuum task CONTEXT: automatic analyze of table "postgres.methylation.methylation" LOG: sending cancel to blocking autovacuum PID 69 DETAIL: Process 68 waits for AccessExclusiveLock on relation 16585 of database 12141. STATEMENT: ALTER TABLE ONLY rnaseq_count ERROR: canceling autovacuum task CONTEXT: automatic analyze of table "postgres.rnaseq.rnaseq_count" LOG: received smart shutdown request LOG: autovacuum launcher shutting down LOG: shutting down LOG: database system was shut down at 2015-04-14 07:52:46 UTC LOG: database system is ready to accept connections LOG: autovacuum launcher started 

为什么在执行加载脚本之前不要尝试安装这个扩展? 类似的东西:

Dockerfile

 ENV DEBIAN_FRONTEND noninteractive RUN apt-get install -y postgresql-plpython3-9.4 

加载脚本

 gosu postgres pg_ctl start -w -D /var/lib/postgresql/data gosu postgres psql -d postgres -c "create language 'plpythonu3';" gosu postgres psql -d postgres -f /dump/dump.sql gosu postgres pg_ctl stop -w -D /var/lib/postgresql/data