我已经创建了数据库的备份并将其复制过来,但是有没有从命令行恢复备份的方法?我只看到与GUI或pg_dumps相关的事情,所以,如果有人可以告诉我如何去做这一切,那将是了不起的!
有两个工具要看,取决于你如何创建转储文件。您的第一个参考源应该是pg_dump(1)的手册页,因为这是创建转储本身的地方。它说:
Dumps can be output in script or
archive file formats. Script dumps are
plain-text files containing the sql
commands required to reconstruct
the database to the state it was
in at the time it was saved. To
restore from such a script,Feed it to
psql(1). Script files can be used
to reconstruct the database even
on other machines and other
architectures; with some modifications
even on other sql database products.The alternative archive file formats
must be used with pg_restore(1) to
rebuild the database. They allow
pg_restore to be selective about what
is restored,or even to reorder the
items prior to being restored. The
archive file formats are designed to
be portable across architectures.
所以取决于它被倾销的方式。你可以使用优秀的文件(1)命令 – 如果它提到ASCII文本和/或sql,它应该用psql恢复,否则你应该使用pg_restore
恢复很容易:
psql -U <username> -d <dbname> -1 -f <filename>.sql
要么
pg_restore -U <username> -d <dbname> -1 <filename>.dump
查看他们各自的manpages – 有很多选项影响恢复的工作原理。您可能必须清除您的“活”数据库或从还原之前的template0(在注释中指出)重新创建它们,这取决于如何生成转储。
总结以上是内存溢出为你收集整理的postgresql – 使用命令行恢复postgres备份文件?全部内容,希望文章能够帮你解决postgresql – 使用命令行恢复postgres备份文件?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)