使用commandprompt将数据恢复到postgresql数据库

时间:2018-01-04 06:02:25

标签: postgresql command-line database-backups database-restore

我在D:\ test中有一个.backup文件;我需要使用命令行恢复此备份。我使用下面的命令。但它没有用;

psql.exe -U username -d dbname -f "d:\backup\myfile.backup"

我也在下面使用

psql -h hostname -U username -d databasename -f "D:\backup\myfil.backup"

1 个答案:

答案 0 :(得分:0)

我想,你在Windows下使用Postgresql。 然后,您必须切换到 pg_restore.exe 所在的目录。

e.g。创建批处理文件:

set DBname=myDatabaseName
set filename=myfile.backup

cd PostgreSQL\9.5\bin\

pg_restore.exe --host localhost --port 5432 --username "postgres" --dbname "%DBname%" --verbose "F:\Backup_DB\%filename%"