开发者

How to create a backup of an POSTGRES DB using bash?

开发者 https://www.devze.com 2022-12-07 23:45 出处:网络
开发者_开发问答How to create a backup of an POSTGRES DB using bash?pg_dump -U some_user_name -f dump.file -Fc database_name
开发者_开发问答

How to create a backup of an POSTGRES DB using bash?


pg_dump -U some_user_name -f dump.file -Fc database_name

That's all.

If you need to authenticate with password - use pgpass file.


Use pg_dump.


Ideally you should add an scheduled job to crontab to be executed daily. The following will create a gzipped sql file with timestamp. SQL dumps otherwise could be very big.

pg_dump database_name | gzip -c > ~/backup/postgres/database_name-`/bin/date +%Y%m%d-%H%M`.sql.gz
0

精彩评论

暂无评论...
验证码 换一张
取 消