Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copying DB to new production env using dokku pg-plugin

Moving from heroku to dokku / digital ocean, I've used pg_dump to copy the database into a file 'latest.dump' and using pg_restore to my local pg db and it worked properly. But when I try to run the dokku postegresql:restore command, it runs and I receive 'database restored' but there are many errors and none of the data is actually restored. Any suggestions for how to troubleshoot / what is causing the errors?

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�;xVM΁9����&��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#��F؁R��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
like image 380
avalente1 Avatar asked Oct 21 '22 10:10

avalente1


1 Answers

I believe a similar problem happened to me when trying to complete a similar task. You need to use a .sql file when uploading the database to your new stack. By default, Heroku gives you a .dump file. What worked for me was copying the database to my local development pg db using the .dump file and then using that to generate a .sql file which I pushed to my new app.

like image 118
murz Avatar answered Oct 23 '22 00:10

murz