Postgres automatic backup in linux

Source: Internet
Author: User
Postgresql automatic backup generates one file every day and compresses it automatically: 1. write a shell script and save it as/home/db/dump. shpg_dumpdb | gzip & gt;/home/db/db((date?policy=m=d=.backup.gz $ (date + % Y % m % d) can be set by yourself. You need to set the execution permission to execute...

Postgresql automatic backup generates one file every day and automatically compresses it:
 
1. write a shell script and save it as/home/db/dump. sh.
Pg_dump db | gzip>/home/db $
You can set $ (date + % Y % m % d) on your own.

You need to set the execution permission to execute
Chmod + x dump. sh
 
Test whether the script can back up the database. Run
Su-postgres/home/db/dump. sh
 
If it is normal, a file named db20110606.backup.gz will be generated.
 
2. add automatic scheduling, execute crontab-e, and add it to the last line (execute at every day ):
Java code
00 3 *** postgres/home/db/dump. sh

3. set/home/db directory permissions:
Java code
Chown postgres. postgres/home/db-R
 
In this case, a compressed file named db20110606.backup.gz is generated every day.
 
Execution Environment:
CentOS 1, 5.3
Postgrsqsql 8.3

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.