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