数据库备份的时候难免会出现一些小问题,本篇文章主要讲解一下odoo的PostgreSQL数据库的备份恢复以及操作:
备份策略:阶段性备份+特定事件备份。周期性自动备份+手动检查+自动通知。
官方参考:https://www.odoo.com/forum/help-1/question/how-to-setup-a-regular-postgresql-database-backup-4728
非并行备份及恢复
使用PostgreSQL的pg_dump和pg_dumpall来备份数据,这两种备份工具都不支持并行备份。
所有备份文件都保存到Master节点,而不是segment节点。一般情况不使用pg_dump,它适用于PostgreSQL迁移到Greenplum。
1、pg_dump
可以在本地及远程进行备份,只需要表的读权限即可备份。pg_dump创建的备份是一致的,在pg_dump运行时数据库产生快照,不阻塞数据库的DML操作,但是会阻塞需要排他锁的操作,如alter table等。特别注意的是,pg_dump一次只能备份一个单独的数据库,且不能备份角色和表空间信息(因为这些信息是cluster-wide,而不是在某个数据库中(per-database))。
命令参数:
$ pg_dump --help
pg_dump dumps a database as a text file or to other formats.
Usage:
pg_dump [OPTION]... [DBNAME]
General options:
-f, --file=FILENAME output file name
-F, --format=c|t|p output file format (custom, tar, plain text)
-i, --ignore-version proceed even when server version mismatches
pg_dump version
-v, --verbose verbose mode
-Z, --compress=0-9 compression level for compressed formats
--help show this help, then exit
--version output version information, then exit
Options controlling the output content:
-a, --data-only dump only the data, not the schema
-b, --blobs include large objects in dump
-c, --clean clean (drop) schema prior to create
-C, --create include commands to create database in dump
-d, --inserts dump data as INSERT, rather than COPY, commands
-D, --column-inserts dump data as INSERT commands with column names
-E, --encoding=ENCODING dump the data in encoding ENCODING
-n, --schema=SCHEMA dump the named schema(s) only
-N, --exclude-schema=SCHEMA do NOT dump the named schema(s)
-o, --oids include OIDs in dump
-O, --no-owner skip restoration of object ownership
in plain text format
-s, --schema-only dump only the schema, no data
-S, --superuser=NAME specify the superuser user name to use in
plain text format
-t, --table=TABLE dump only matching table(s) (or views or sequences)
-T, --exclude-table=TABLE do NOT dump matching table(s) (or views or sequences)
-x, --no-privileges do not dump privileges (grant/revoke)
--disable-dollar-quoting disable dollar quoting, use SQL standard quoting
--disable-triggers disable triggers duri