Sunday, February 24, 2008

PostgreSQL Backups

While shell scripting is not my strong suit I put this together to do automatic backups of the Postgres database that backs the services. The script will vacuum each database, do a full dump of each database, do a dump of each schema and do a global meta-data backup. All the dumps are compressed with bzip2 and date/time stamped. Logs and backups older than 7 days are removed.

The results get stored in a date-stamped directory and all actions are logged into a date/time stamped log file.

The script can be easily customized using the variables at the top of the file and should work on any PostgreSQL database.

No comments: