简体   繁体   English

从pg_dumpall(Ubuntu)进行PostgreSQL备份

[英]PostgreSQL Backup from pg_dumpall (Ubuntu)

I was tasked with writing a python script to backup our current instance of Alfresco ECM. 我的任务是编写一个Python脚本来备份我们当前的Alfresco ECM实例。 The backup works like a charm. 备份的工作原理很简单。 I am running into problems with restoring PostgreSQL from the text dump .sql file. 我从文本转储.sql文件还原PostgreSQL时遇到问题。

Here is my command: 这是我的命令:

psql -f /home/alfresco/alfresco-backup/20180124/20180124_183146.sql -h 
localhost

Here is the response: 这是响应:

psql: FATAL:  database "postgres" does not exist

I can not find any information on this online. 我在网上找不到任何信息。 I have looked deeply into Postgres documentation and found nothing. 我深入研究了Postgres文档,却一无所获。

Thank you. 谢谢。

You are getting this error because you are not specifying database name in command and its defaulting to postgres for database name. 由于没有在命令中指定数据库名称,而数据库名称默认为postgres,因此出现此错误。 You can use pg_dump to backup database. 您可以使用pg_dump来备份数据库。 Here is how you run a pg_dump command. 这是运行pg_dump命令的方式。

pg_dump -U db_user -W -F t db_name > /path/to/your/file/dump_name.tar

It seems like the postgres and the template1 databases have been deleted. 似乎postgrestemplate1数据库已被删除。 That shouldn't happen. 那不应该发生的。

Use initdb to create a new, healthy DB cluster. 使用initdb创建一个新的健康数据库集群。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM