Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 4D02A2E0055 for ; Wed, 7 May 2008 17:03:02 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 62042-06 for ; Wed, 7 May 2008 17:02:56 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from wr-out-0506.google.com (wr-out-0506.google.com [64.233.184.234]) by developer.postgresql.org (Postfix) with ESMTP id 34C3E2E0047 for ; Wed, 7 May 2008 17:02:59 -0300 (ADT) Received: by wr-out-0506.google.com with SMTP id 76so239286wra.10 for ; Wed, 07 May 2008 13:02:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; bh=g7mTDflVqwXbURvl0MWJc1L8e+SjogKjDxJ+X/bQQl8=; b=r+TRiMh7u14ADHY2ZGraMpZVBkRv8t5LOGhVf/7s3DSbYSe08vf1rvJ0jABg0GPIp7qbffgi+0o/pwqhXTeSfT4VUv1EMLOq8d/dBmdK28cvj2uK7gPa3cP4KuCBQZwN/EflUz3rkAEPHClkYmpV5HK2T6yqmiRRr+OGmERtbYQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=CCzK+RVjr9DWpx7C6uMFaQutogzMgxKLrYDLYhaG8+8FuAXXx1tGY2DTDM8nT/GKBEcHyC6RP8vYNBrfJFTXOF7doA1WDy4s/+qywxx5qa5VusKhyv739G1wdsnKfWVxra2dHtlPB6a4bs1JgII920w6bsx1AtrpynZR3llOh1s= Received: by 10.100.91.17 with SMTP id o17mr3404961anb.90.1210190578149; Wed, 07 May 2008 13:02:58 -0700 (PDT) Received: by 10.100.214.12 with HTTP; Wed, 7 May 2008 13:02:57 -0700 (PDT) Message-ID: Date: Wed, 7 May 2008 13:02:57 -0700 From: "John Smith" To: pgsql-general@postgresql.org Subject: Backup/Restore of single table in multi TB database MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/237 X-Sequence-Number: 132636 Hi, I have a large database (multiple TBs) where I'd like to be able to do a backup/restore of just a particular table (call it foo). Because the database is large, the time for a full backup would be prohibitive. Also, whatever backup mechanism we do use needs to keep the system online (i.e., users must still be allowed to update table foo while we're taking the backup). After reading the documentation, it seems like the following might work. Suppose the database has two tables foo and bar, and we're only interested in backing up table foo: 1. Call pg_start_backup 2. Use the pg_class table in the catalog to get the data file names for tables foo and bar. 3. Copy the system files and the data file for foo. Skip the data file for bar. 4. Call pg_stop_backup() 5. Copy WAL files generated between 1. and 4. to another location. Later, if we want to restore the database somewhere with just table foo, we just use postgres's normal recovery mechanism and point it at the files we backed up in 2. and the WAL files from 5. Does anyone see a problem with this approach (e.g., correctness, performance, etc.)? Or is there perhaps an alternative approach using some other postgresql mechanism that I'm not aware of? Thanks! - John