博文

目前显示的是标签为“数据库”的博文

备份PostgreSQL数据库

0. 若1提示`Peer authentication failed for user`, 修改`pg_hba.conf`这一行: /etc/postgresql/9.5/main/pg_hba.conf ``` local   all             all                                     peer ``` --> ``` local   all             all                                     password ``` https://dba.stackexchange.com/questions/51342/cant-backup-a-postgres-database-fatal-peer-authentication-failed-for-user-po 1. pg_dump命令进行备份: ```bash pg_dump database_name --username=user > postgres.bak ``` https://www.postgresql.org/docs/9.5/static/backup-dump.html 2. 验证正确备份: 备份的内容为文本格式. 可用`less` `nano`分块查看内容是否正确(比如搜索表名/数据实例). 3. 压缩. 设置密码. 4. 若0, 恢复修改的部分.