如何从.tar文件恢复PostgreSQL数据库?

我使用WHM在增量备份期间备份了所有PostgreSQL数据库,后者创build了一个$ dbName。 tar文件。

数据存储在这些.tar文件中,但我不知道如何通过SSH将其还原到各个数据库中。 特别是文件的位置。

我一直在使用:

pg_restore -d client03 /backup/cpbackup/daily/client03/psql/client03.tar 

这会产生错误“无法打开input文件:权限被拒绝”

任何援助感激。

find正确的代码串,以防其他人发现这个线程。

 pg_restore -c -i -U postgres -d client03 -v "/tmp/client03.tar" -W 

分解是从http://www.postgresql.org/docs/7.3/static/app-pgrestore.html和一些试验和错误。

从本质上讲…

 -c to clean the database -i to ignore any database version checks -U to force a user -d to select the database -v verbose mode, don't know why "$$" the location of the files to import in tmp to get around permission issues -W to force asking for the password to the user (postgres) 

希望以上协助别人。

我不确定它可以导入.tar文件。 我会做一个

 tar -zxvf client03.tar 

提取文件中的任何内容,然后再次尝试pg_restore。 我知道pg_restore的作品,因为我们有从裸机恢复相同的恢复方法。

当使用PgAdmin III为我进行恢复时,使用它自己构build的以下命令完美地工作:

 pg_restore --host localhost --port 5432 --username "my_user_name" --dbname "my_db_name" --role "my_user_name" --no-password --verbose "/Users/me/Desktop/backup_file.tar" 

请注意,为避免警告,在备份文件中拥有对象所有者的angular色已经存在于目标服务器中是一个好主意。 此外,您应该已经拥有由该angular色创build和拥有的目标数据库。

下面是通过点击数据库并右键单击并select恢复从pgAdmin iii为我生成的。 我导航到我有的.tar文件,它自己做的。

 /usr/bin/pg_restore --host localhost --port 5434 --username "postgres" \ --dbname "dvdrental" --no-password --schema public --verbose \ "/home/npena/Desktop/dvd/dvdrental.tar" 

对于V9.5,请在命令行中运行以下命令

pg_restore -W -c -U [username] -d [database_name] -v "[path to extracted tar]"