14

コマンドラインからデータベース「mydatabase」をテキストファイル「mydatabase.sql」にダンプしています。

"C:/Program Files (x86)/PostgreSQL/9.1/bin/pg_dump.exe " --host localhost --port 5432 --username "postgres" --no-password --verbose --file "C:\Users\User 1\Desktop\mydatabase.sql" "mydatabase"

うまくいっています。しかし、何度も試した後、それらのファイルをデータとともにデータベースにpg_restoreすることはできません。
しかし、このデータベース内のすべてのテーブルを削除すると、次のように実行できます。

psql -f "C:\Users\User 1\Desktop\mydatabase.sql" "mydatabase" "postgres"

これにより、すべてのデータが回復されます。問題は、VBNET / shellを介してpgslを実行できないため、pg_restore.exeが必要になることです。これが私の試みです。

"C:/Program Files (x86)/PostgreSQL/9.1/bin/pg_restore.exe " -i -h localhost -p 5432 -U postgres -d "mydatabase" -v "C:\Users\User 1\Desktop\mydatabase.sql"

...メッセージが表示される場所:

C:\ Users \ User 1> "C:/ Program Files(x86)/PostgreSQL/9.1/bin/pg_restore.exe" -i -h localhost -p 5432 -U postgres -d "mydatabase" -v "C:\ Users \ User 1 \ Desktop \ mydatabase.sql"無効なバイナリ"C:/ Program Files(x86)/PostgreSQL/9.1/bin/pg_restore.exe "pg_restore.exe:[archiver]入力ファイルが有効なアーカイブではないようです

復元を試みる前に、サーバー上に空のデータベース「mydatabase」があります(テーブルなし)。pg_dumpでダンプされ、明らかに適切なデータが含まれている「mydatabase.sql」でpg_restoreを機能させるために、助けを借りてください。純粋なコマンドラインまたはVBNET/シェルで使用できます。

4

1 に答える 1

12

pg_dumpで、-F tフラグを指定します。これにより、pg_dumpにtar形式でバックアップを作成するように指示されます。これは、pg_restoreを介した復元に適しています。

"C:/Program Files (x86)/PostgreSQL/9.1/bin/pg_dump.exe " --host localhost --port 5432 --username "postgres" --no-password --verbose -F t --file "C:\Users\User 1\Desktop\mydatabase.sql" "mydatabase"
于 2012-12-04T13:44:05.443 に答える