I'd like to use WAL archiving for incremental backup of my database. But I have 2 databases on my server, and I can't afford the disc space for backup of both of them. So I only want to backup one of them. I didn't find anything about multiple databases in PostgreSQL documentation or anywhere else. Or I didn't find anything about specifying the database name for WAL backup. It will be appreciated if someone can help me with this.

  • 1
    Not possible as far as I know. WAL archiving can only be done for the whole Postgres cluster.
    – user1822
    Oct 23, 2012 at 8:18
  • 1
    I would suggest that disk space is relatively cheap. But it's a trade off between that and effective usage of your server's memory if you go down the route of running multiple clusters. Oct 23, 2012 at 9:17
  • 1
    @Colin'tHart 9.3 should improve the memory trade-off somewhat, now that Pg can use mmap()ed anonymous memory instead of System V shared memory for shared_buffers. Oct 23, 2012 at 10:24
  • For people reading this in future when 9.3 is released :-) Oct 23, 2012 at 10:26
  • 1
    May running two separate PG instances/clusters be a solution?
    – dezso
    Oct 23, 2012 at 17:06

1 Answer 1


You can't split WAL archiving out so one database goes in one WAL archive stream and other DBs go in another WAL archive stream. A single write-ahead log is shared by all databases in a PostgreSQL server ("cluster" in PostgreSQL parlance). All databases managed by a postmaster have the same WAL. This is a sometimes unfortunate limitation of the current replication/PITR/archiving design and is true for the in-development-at-time-of-writing 9.3 and all and prior releases.

If you want to separate the WAL archiving, you have to separate the databases into different clusters. You can do this by running more than one instance of PostgreSQL on a server; they simply have to have different data directories and different listening ports. Some packagings of PostgreSQL provide built-in tools to do this, like the pg_wrapper tool used on Debian and Ubuntu, which has pg_createcluster. Alternately, you can always just use initdb to create a cluster and pg_ctl to start the cluster after editing the new cluster's postgresql.conf to set an appropriate port.

Tools like pgbouncer may be used, if desired, to multiplex the multiple clusters transparently, so pgbouncer listens on port 5432 (the default Pg port) and decides which server to send the connection to based on which database it asks for. Generally it's easier to just specify a port in the connection setup of the applications that use each database, though.

On PostgreSQL 9.2 and below you must allocate each server an exclusive, non-overlapping shared memory region for its shared_buffers. One server cannot make use of the other server's shared_buffers space when the other server is not busy. That means you are wasting some system resources. PostgreSQL 9.3 improves this by allocating shared_buffers out of anonymous memory, giving the OS more freedom about how it manages it.

If you don't want to run multiple clusters, you can use alternative replication or backup solutions based on out-of-tree tools like Slony-I, Bucardo, etc to manage your data replication and archival.

  • According to what I read (wiki.postgresql.org/wiki/Warm_Standby), other PITR tools are using the WAL system themselves. So I think they do not offer any solution to my problem with 2 databases. So what is the advantage of using them for my database incremental backup instead of setting up the WAL archiving myself?
    – Sina
    Oct 23, 2012 at 22:07
  • @Sina Where did I suggest using warm standby? I pointed out row-level replication tools like Bucardo and Slony-I. Oct 23, 2012 at 22:20
  • I had problem finding anything related to PITR in Slony-I and Bucardo documentations. It will be great if you help me with this. And also which way do you recommend? Seperating databases into different clusters and using the wal backup of the postgre, or using some other tool?
    – Sina
    Oct 28, 2012 at 16:26
  • @Sina Re Bucardo and Slony, see this page I linked to above: wiki.postgresql.org/wiki/… . As for how to do it: Slony-I is complicated, I don't advise using it unless you really know you need it. Bucardo is great when you're just replicating a few tables, but isn't as good if you need to replicate DDL changes or lots of tables. Splitting the cluster and using built-in streaming replication is best if you need it simple or you have several DBs or lots of tables or lots of DDL to replicate. Oct 28, 2012 at 22:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.