PostgreSQL Extension
Prev | Chapter 6. Official Extensions | Next

## PostgreSQL Extension

The PostgreSQL Extension is a Cedar Backup extension used to back up PostgreSQL [27] databases via the Cedar Backup command line. It is intended to be run either immediately before or immediately after the standard collect action.

The backup is done via the pg_dump or pg_dumpall commands included with the PostgreSQL product. Output can be compressed using gzip or bzip2. Administrators can configure the extension either to back up all databases or to back up only specific databases.

The extension assumes that the current user has passwordless access to the database since there is no easy way to pass a password to the pg_dump client. This can be accomplished using appropriate configuration in the pg_hda.conf file.

This extension always produces a full backup. There is currently no facility for making incremental backups.

### Warning

Once you place PostgreSQL configuration into the Cedar Backup configuration file, you should be careful about who is allowed to see that information. This is because PostgreSQL configuration will contain information about available PostgreSQL databases and usernames. Typically, you might want to lock down permissions so that only the file owner can read the file contents (i.e. use mode `0600`).

To enable this extension, add the following section to the Cedar Backup configuration file:

    <extensions>
       <action>
          <name>postgresql</name>
          <module>CedarBackup2.extend.postgresql</module>
          <function>executeAction</function>
          <index>99</index>
       </action>
    </extensions>

This extension relies on the options and collect configuration sections in the standard Cedar Backup configuration file, and then also requires its own `postgresql` configuration section. This is an example PostgreSQL configuration section:

    <postgresql>
       <compress_mode>bzip2</compress_mode>
       <user>username</user>
       <all>Y</all>
    </postgresql>

If you decide to back up specific databases, then you would list them individually, like this:

    <postgresql>
       <compress_mode>bzip2</compress_mode>
       <user>username</user>
       <all>N</all>
       <database>db1</database>
       <database>db2</database>
    </postgresql>

The following elements are part of the PostgreSQL configuration section:

`user`

  Database user.

  The database user that the backup should be executed as. Even if you list more than one database (below) all backups must be done as the same user.

  This value is optional.

  Consult your PostgreSQL documentation for information on how to configure a default database user outside of Cedar Backup, and for information on how to specify a database password when you configure a user within Cedar Backup. You will probably want to modify pg_hda.conf.

  Restrictions: If provided, must be non-empty.

`compress_mode`

  Compress mode.

  PostgreSQL databases dumps are just specially-formatted text files, and often compress quite well using gzip or bzip2. The compress mode describes how the backed-up data will be compressed, if at all.

  Restrictions: Must be one of `none`, `gzip` or `bzip2`.

`all`

  Indicates whether to back up all databases.

  If this value is `Y`, then all PostgreSQL databases will be backed up. If this value is `N`, then one or more specific databases must be specified (see below).

  If you choose this option, the entire database backup will go into one big dump file.

  Restrictions: Must be a boolean (`Y` or `N`).

`database`

  Named database to be backed up.

  If you choose to specify individual databases rather than all databases, then each database will be backed up into its own dump file.

  This field can be repeated as many times as is necessary. At least one database must be configured if the all option (above) is set to `N`. You may not configure any individual databases if the all option is set to `Y`.

  Restrictions: Must be non-empty.

[27] See http://www.postgresql.org/

Prev | Up | Next
MySQL Extension | Home | Mbox Extension