I try through DB::statement(Storage::get('tmp/test.backup')); restore the postgresql dump, but I get this error:

 SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "1" LINE 316: 1 1 2 1 {"1":"\\u041f\\u0435\\u0440\\u043c\\u044c","2":"\\u0... ^ (SQL: -- -- PostgreSQL database dump -- 

lines in dump:

 COPY blocks (id, "order", tab_id, type_id, content) FROM stdin; 1 1 2 1 {"1":"\\u041f\\u0435\\u0440\\u043c\\u044c","2":"\\u041e\\u043f\\u0438\\u0441\\u0430\\u043d\\u0438\\u0435 \\u043f\\u0435\\u0440\\u043c\\u0438","3":2015,"4":"tratatatata.png"} \. 

dumped with the command:

 $process = new Process('pg_dump business_card_base --schema test > '.storage_path('app/tmp/').'test.backup'); 

laravel 5.1, Postgresql 9.3.9

what could be wrong?

    1 answer 1

    The error is that the dump is not an ordinary sql, the dump needs to be loaded via psql -f tmp/test.backup . Unfortunately, I am not guided in laravel, but apparently there will be something like:

     $process = new Process('psql -f '.storage_path('app/tmp/').'test.backup'); 
    • That's what he did. But since this happens inside a transaction - it will not work, by the fact that the scheme I am recovering from the dump still exists =) - Pavel Sotnikov
    • one
      Not quite clear, you only want to wrap the recovery into a transaction, then - single-transaction . Or do you want to do something in your transaction, restore the base, do something, roll back - here, in my opinion, it is unlikely that you may need to look for alternative backup options, right up to your bike ... - Yura Ivanov
    • The second option =) - Pavel Sotnikov
    • one
      What a mysterious you are :) Well, the problem is, you need to look for approaches. I would start by generating DDL with --schema-only, if it works like a normal statement, you can jot down a script to upload data in the ansi form ... well, something like that. You have a very unusual usecase, you have to dodge ... - Yura Ivanov