Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6667743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:57:56+00:00 2026-05-26T02:57:56+00:00

Site A will be generating a set of records. Nightly they will backup their

  • 0

Site A will be generating a set of records. Nightly they will backup their database and ftp it to Site B. Site B will not be modifying those records at all, but will be adding more records and other tables will be creating FK’s to Site A’s records.

So, essentially, I need to setup a system to take all the incremental changes from Site A’s dump (mostly inserts and updates, but some deletes possible) and apply them at Site B.

At this point, we’re using Postgres 8.3, but could upgrade if valuable.

I believe I can do this relatively straight-forwardly with Bucardo but I’d love to hear alternatives (or confirmation of Bucardo) before I setup a linux box to test it out.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:57:57+00:00Added an answer on May 26, 2026 at 2:57 am

    Most every replication solution would do your trick. The Postgres Wiki has a chapter on the topic. But your case is simple enough. I would just use dblink.
    This is generalized from a working implementation of mine:

    1. Create a view in the master db that returns updated rows.
      Let’s call it myview.

    2. Create one function per table in the slave db that fetches rows via dblink:

    CREATE OR REPLACE FUNCTION f_lnk_mytbl()
      RETURNS TABLE(col_a integer, col_b text, col_c text) AS
    $func$
       SELECT *
       FROM   public.dblink('SELECT col_a, col_b, col_c FROM myview')
                          AS b(col_a integer, col_b text, col_c text);
    $func$  LANGUAGE sql SECURITY DEFINER;
    
    REVOKE ALL ON FUNCTION f_lnk_mytbl() FROM public;
    GRANT EXECUTE ON FUNCTION f_lnk_mytbl() TO my_user;
    
    1. Use above function in another function in the slave db that establishes and closes the server connection.
    CREATE OR REPLACE FUNCTION f_mysync()
      RETURNS void AS
    $func$
    BEGIN
       PERFORM dblink_connect(
              'hostaddr=123.45.67.89 port=5432 dbname=mydb user=postgres password=secret');
    
       -- Fetch data into local temporary table for fast processing.
       CREATE TEMP TABLE tmp_i ON COMMIT DROP AS
       SELECT * FROM f_lnk_mytbl();
    
       -- *Or* read local files into temp tables with COPY so you don't need dblink.
       -- UPDATE what's already there (instead of DELETE, to keep integrity).
       UPDATE mytbl m
       SET   (  col_a,   col_b,   col_c) =
             (i.col_a, i.col_b, i.col_c)
       FROM   tmp_i i
       WHERE  m.id = i.id
       AND   (m.col_a, m.col_b, m.col_c) IS DISTINCT FROM
             (i.col_a, i.col_b, i.col_c);
    
       -- INSERT new rows
       INSERT INTO mytbl
       SELECT * FROM tmp_i i
       WHERE  NOT EXISTS (SELECT 1 FROM mytbl m WHERE m.id = i.id);
    
       -- DELETE anything? More tables?
    
       PERFORM dblink_disconnect();
    END
    $func$  LANGUAGE plpgsql SECURITY DEFINER;
    
    REVOKE ALL ON FUNCTION f_mysync() FROM public;
    GRANT EXECUTE ON FUNCTION f_mysync() TO my_user;
    
    1. Now, this call is all you need. Call as superuser or as my_user. Schedule a cronjob or something.
    SELECT f_sync_mytbl();
    

    In PostgreSQL 9.1 or later there is also the new CREATE FOREIGN TABLE. Might be more elegant.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I notice on bad quality websites with ads a piece of the site will
I'm developing an online store with Magento. The site will be high traffic and
HELP!! I need to bundle a gem otherwise a published client's site will stay
I am planning a new website with codeigniter using wordpress. this site will contain
I'd like everything to function correctly, except when it's mobile, the entire site will
We will develop a web site that will have some free services and we
I have a site that will require a login by the users. The client
I am building a site that will (obvisouly) have a front end public portion
I need to create a WP site which will have multiple subjects. Each subject
How to design a Web Site that will fit to Mobile and Desktop both,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.