PostgreSQL Backup PERL Script


News

[06-jun-2007] Version 0.93 released, with bug fixes and improvements. Get it at the download page.

Introduction

This script was made with the intent of remotely organizing and maintaining PostgresSQL database backups. It uses the 'psql' binary to remotely connect and generate backups for the target databases, and only of the tables that need backup. On large databases, backuping the whole schema generates too much data.

Status

The current version is marked as Beta for a single reason: It has been only tested in my own databases.
It has already being used for over 6 months without problems, but if you decide to used it, it is HIGHLY RECOMMENDED THAT YOU VALIDATE THE BACKUPS generated before you start trusting them.

Requirements


Download


Features


Documentation

The first thing you need is to make sure the script has the right path to the postgres binaries. so if your postgres installation is not in /usr/local/pgsql/bin, edit the script and change the path to the right one.

XML Files

When run in automatic mode, the script will generate one backup for each .bkp.xml file it finds inside the ./data subdir.
These Files are in the format:
     <?xml version='1.0'?>

        <database ip="999.999.999.999" port="5432"
        name="DATABASE_NAME"
        user="USERNAME"
        password="PASSWORD"

        schema="SCHEMA"
        save_dir="/place/to/put/the/backups/"
        excludedTables="SKIP_TABLE1, SKIP_TABLE2, SKIP_TABLE3"
        mailTo="sendWarningsTo@databaseadmim.com"
        keep_last="NUMBER_OF_BACKUPS_TO_KEEP">

      <table name="BACKUP_THIS_TABLE" type="full"/>
      <table name="BACKUP_THIS_TOO" type="full"/>
    </database>
Where:


Command Prompt

For quick testing and exporadic backups, the command prompt can be used. Just run the script without arguments.
The followin commands will be available:

Command Line


TODO


Help Wanted

I have very little time right now to work on this project, so if you think you can help improve it, please contact me.

Contact

If you have some question and or improvement of the script, please email me: marcio.pgbackupscript@gmail.com. As any expert PERL programmer will notice, I am not one. So optimizations are welcomed.