Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

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.

share|improve this question
1  
Not possible as far as I know. WAL archiving can only be done for the whole Postgres cluster. –  a_horse_with_no_name Oct 23 '12 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. –  Colin 't Hart Oct 23 '12 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. –  Craig Ringer Oct 23 '12 at 10:24
    
For people reading this in future when 9.3 is released :-) –  Colin 't Hart Oct 23 '12 at 10:26
    
@Colin'tHart Or those nuts enough to run it now when it's still undergoing rapid catalog version increments. Yes, in future when it's released it should improve things; 'till then the shared memory split is going to hurt. –  Craig Ringer Oct 23 '12 at 13:14

1 Answer 1

up vote 1 down vote accepted

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.

share|improve this answer
    
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 '12 at 22:07
    
@Sina Where did I suggest using warm standby? I pointed out row-level replication tools like Bucardo and Slony-I. –  Craig Ringer Oct 23 '12 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 '12 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. –  Craig Ringer Oct 28 '12 at 22:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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