Chapter 8. Routine Database Maintenance Tasks

General Discussion

There are a few routine maintenance chores that must be performed on a regular basis to keep a PostgreSQL installation running smoothly. The tasks discussed here are repetitive in nature and can easily be automated using standard Linux tools such as cron scripts. But it is the database administrator's responsibility to set up appropriate scripts, and to check that they execute successfully.

One maintenance task is creation of backup copies of the data on a regular schedule. Without a recent backup, you have no chance of recovery after a catastrophe (disk failure, fire, mistakenly dropping a critical table, etc.). The backup and recovery mechanisms available in PostgreSQL are discussed in Chapter 7.

Other routine tasks recommended to keep your PostgreSQL installation running smoothly are periodic "vacuuming" and log file maintenance. Appropriate attention to these tasks will go far towards ensuring a pleasant and productive experience with the system.