从heroku转移到dokku / digital ocean,我使用pg_dump将数据库复制到文件'latest.dump'并使用pg_restore到我的本地pg db并且它正常工作。但是当我尝试运行dokku postegresql:restore命令时,它运行并且我收到“数据库已恢复”,但是有很多错误,并且没有任何数据实际恢复。有关如何排除故障/导致错误的原因的任何建议吗?
root@domain:~# dokku postgresql:restore db_name < dokku/db/latest.dump
ERROR: syntax error at or near "PGDMP"
LINE 1: PGDMP
id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: version character varying(255) NOT NULL
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: id integer NOT NULL,
^
ERROR: syntax error at or near ""
LINE 1: START WITH 1
^
ERROR: syntax error at or near ""
LINE 1: _time, early_l...
^
ERROR: syntax error at or near "_price"
LINE 1: _price, delivery_counter, credit_card, yrd_per) FROM stdin;
^
ERROR: syntax error at or near "ADD"
LINE 1: ADD CONSTRAINT adjustments_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT clients_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT contacts_tables_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT deliveries_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT devices_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT drivers_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT groups_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT invoices_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT jobs_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT locations_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT materials_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT messages_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT mixes_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT orders_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT payments_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT plants_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT products_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT statements_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT tags_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT trucks_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT users_pkey PRIMARY KEY (id);
^
ERROR: syntax error at or near ""
LINE 1: ADD CONSTRAINT workdays_pkey PRIMARY KEY (id);
^
invalid command \
invalid command \
invalid command \�/x$Ր�8X~`�O`�����*a
�ЛU[2u^����ar���m��kU�"���!���c,Llel��ˀ��u�ʚb[
invalid command \�n
invalid command \$�I�m�
ɤ�HK��
invalid command \�}�b����7�6�]D�x�����|��l�D�Y}�P��A�T�װLJ��.{�ۇ�{c�bܤ��
invalid command \2��h[�/!I��${�7�@lHhLD���dÄG@�P�rL���qtkU����Iܩ&$�i�I��=0!�
invalid command \��`.���y���,�{0B�z�f3�^��?q�
invalid command \W���WIJ����lQ�
invalid command \r�9�S܀�fk�
invalid command \螀ܠ��T��g���eXx{j��8����x�Xt6�
invalid command \~zʘ�Z���OiƘbl}#p�E��.�;א}{8I��b�]��Rf�1��0
invalid command \q�6|P
��o��j���I���V
^��S
invalid command \��(��D����a����B(�ϓ]n�~Љ��������W����
invalid command \$�a��s8�5g��:�=@�!^�L6�0mjO;3��/�Ei7��)�Xp�K�
invalid command \�����q�P�ZF��
ERROR: syntax error at or near ""
LINE 1: ��kη�>6�x�
E�����U����d�]T���&
��_E>p��k��In�~�...
^
invalid command \x�6�`YIk
invalid command \�Q��8�
<¼��njWڡ��
invalid command \դ�n�|��p�ҍ���gve�d�]�{�/Ó+�Q�.�NQ�s��z)`SI.��v�8�U��[ͮi�Z�������FU
invalid command \�M�>=���7�;��4�!y25�J�������E=��(�LS֜{�S�I�3;
invalid command \ʑ<�0b<��Jm��y�]��9�B���V(��#��?���{�m�]AVv3嘫�f�Q�X=���
invalid command \l�I�W.
invalid command \��i���Tc��^���
invalid command \�刄��+�u�
invalid command \([����&DrLL�NC�l���E�J��uR��c�HQ�e*e�e8�V?R/�y���O�S��.+c��7E�V5�K��ɵC'��
invalid command \�
invalid command \'�Ε]���[ޮ���h�J/RV=�'�v�7m�z�-�,���v]�X�����Z%�5��P�jYi�.�N,���[δ���v��1`���n�օ��h
invalid command \�Wb���'�B-62y��
invalid command \�������sl�Q�
ERROR: syntax error at or near "Lnܚ"
LINE 1: Lnܚ��H�f�2U�Q���"��C��4(+6a�0EF?�*:�'=��^�^i� �T�)�...
^
invalid command \#i�ě��(������g���ժ�`Q˅&�O{�F������%��u�(GEMW��0�����G���}1�8�u��rF�V4�Y4:�'�h���ݟ�M�8�Q�
invalid command \'g�7�Zo����@i���R��jY��u*%��E���ց��s��M�'�#�d��<9�?���&�Rd�v�TTj3B=>��]Y6DsT�hǃ���=w�D�M47��!2�B�%�f��)S�ʽJr���8;��].x^�Vv�ɸ7����'R��BG5��rMt�F��&���{�)�B�����_~����f��*���ۻLJ���wo�m�{|����.�����������w��e9�&g�Ə�lNQ�<|�6˙��u��f��p��40�1g]�0ő�թ��-+�M��r����+���e�+�i���s݂�����b��y�ݾy>���S��m�2nUǨ���x[v�vخ�yec�h3[-}����N�s��:^�p���%�ʑ�I�ŸO������5Ģ!Bj�h��
ERROR: syntax error at or near "2"
LINE 1: 2^͗i��u� ���U�9zD>����(���q�ϫCw��O��6Q[D��...
^
invalid command \��Q%�,~�
invalid command \S��C�
�
ERROR: syntax error at or near "�3��"
LINE 1: �3��� ��0� V�[�� �Bz2K�W�1�X�:��|E{2� D���+sQ�...
^
ERROR: syntax error at or near "˭�y��"
LINE 1: ˭�y��
���4�:��Rz�g+�����ɲ�U+1�V
�"�
^
invalid command \Y8��t��.
invalid command \�;�K
ERROR: syntax error at or near "Y��"
LINE 1: Y��]�hI?w}8�U��C�K��`2c���/��]*NTG+�����
&ai��-w...
^
invalid command \���:vH*a7���g�7uZ����ƴ5j8���
invalid command 0��M���-U0�9�+���b,R�
ERROR: syntax error at or near "��9�"
LINE 1: ��9�
�UD6q�)�LѴ��L�I�U��t�g��t�;xVM9����&��o����OO...
^
invalid command \ܯո�i$0��2�i�
invalid command \�0�2�$�XM�Y�r�i�7�k�e����������~z}�"�&��H(�
invalid command \Z�3��F�6t�
invalid command \O�k�i�|�bJ�+�$ٝHO�j_�ƲF���S�R���Z�
invalid command \sȗ�������Zu�/�>ddz��Mr���G��Y���wi�����p��[����Cw�#�&�K���$j�w�|wa�����
invalid command \�d���j���
invalid command \[9ד���sPFo���c�S��>���hG>GOߥ��;��۞Z��`�6�Aa
invalid command \���g<Y��I#��FR��V�
invalid command \w��枎�S�%����=uR��7
invalid command \�k'�#��li��P4��F�I��^E��߷��7
invalid command \��onC�!�CX�;1����s�yFdy2�G���'S�82��
invalid command \��V���Bh{�
invalid command \��s���`
invalid command \�N&h�:31$�Mul+��k��<.�b�Z���g.�YUn1^�u�"GƇ�@Ʈ�.�>ߙ�h
invalid command \�xIrK�2
ERROR: syntax error at or near "�"
LINE 1: ��I��}*X�L����_���%��~8gt�ȃ�l�BZ,˹��s]��d�����h�e�a/
^
invalid command \k�
Nj��@��#���79M��L�|�o�6Lᘪ��[&�[(��*�
ERROR: syntax error at or near "�"
LINE 1: �
^
-----> db_name database restored
答案 0 :(得分:2)
我相信在尝试完成类似的任务时,我遇到了类似的问题。将数据库上载到新堆栈时,需要使用.sql文件。默认情况下,Heroku会为您提供.dump文件。对我有用的是使用.dump文件将数据库复制到我的本地开发pg db,然后使用它生成一个.sql文件,我将其推送到我的新应用程序。
答案 1 :(得分:0)
这对我有用:
pg_restore -O latest.dump | dokku postgresql:restore <db_name>