问题描述
我是Postgres数据库的新手.我必须从Production Server(pgAdmin版本为9.2.4)中获取备份,并且将其还原到我的本地计算机上(我具有pgAdmin版本9.4).我试图通过右键单击数据库->备份以获取.backup文件来获取备份.如下图所示:
I am new to Postgres database. I have to get the backup from Production Server (pgAdmin Version is 9.2.4) & restore it on my local machine (I have pgAdmin Version 9.4). I tried to get backup by right clicking on database -> Backup to get the .backup file. Like shown in below image:
但是当我尝试还原备份文件时,出现很多错误.
But when I try to restore the backup file, I get many errors.
我还想知道两个系统上使用不同的端口在还原备份时是否也会造成问题.正如我尝试还原同一系统的备份时没有问题.
I also want to know whether having different ports at both system can also create issues while restoring backups. As When I tried to restore backup of same system had no problems.
推荐答案
要备份数据库,可以使用pg_dump.exe
:
- 打开命令行窗口
-
转到Postgres bin文件夹.例如:
- Open command line window
Go to Postgres bin folder. For example:
cd "C:\Program Files\PostgreSQL\9.6\bin"
输入命令以转储数据库.例如:
Enter the command to dump your database. For example:
pg_dump.exe -U postgres -d MediaData -f D:\Backup\<backup-file-name>.sql
为您的postgres用户输入密码
Type password for your postgres user
要还原数据库,可以使用psql.exe
. (请注意,以下摘录自Alexandr Omelchenko的有用答案,由于我不清楚的原因,该答案已被删除.)
- 打开命令行窗口
-
转到Postgres bin文件夹.例如:
- Open command line window
Go to Postgres bin folder. For example:
cd "C:\ProgramFiles\PostgreSQL\9.5\bin"
输入命令以还原数据库.例如:
Enter the command to restore your database. For example:
psql.exe -U postgres -d MediaData -f D:\Backup\<backup-file-name>.sql
为您的postgres用户输入密码
Type password for your postgres user
这篇关于如何备份和备份在Windows7中还原PostgreSQL数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!