Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gmbov-0003F4-UT for pgsql-general@arkaria.postgresql.org; Thu, 24 Jan 2019 10:01:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gmbou-00009t-Df for pgsql-general@arkaria.postgresql.org; Thu, 24 Jan 2019 10:01:12 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gmbou-00007l-24 for pgsql-general@lists.postgresql.org; Thu, 24 Jan 2019 10:01:12 +0000 Received: from mail-oi1-x230.google.com ([2607:f8b0:4864:20::230]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gmbor-0007RS-QV for pgsql-general@lists.postgresql.org; Thu, 24 Jan 2019 10:01:10 +0000 Received: by mail-oi1-x230.google.com with SMTP id j21so4348072oii.8 for ; Thu, 24 Jan 2019 02:01:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=k46e9uXxihG+jQfepToA8x6gQvaNcSd2eVQ3abDuc3E=; b=MblGRPnZzMFT0rUURczo0sXWI9UzZvYlVmkHpZ2lDDqxH4u62X8h0XB0/4JUYhnDQL SHQz+YEG2VfxywL5tIl6oZmX6F0dcP8gytezi8zExRG6YQXNK8ojSNgobetrwGmnCeof PboaVlzcFDkle6zPNhwWVDeOH5DbRo4j1k1aOLCRPuDMavH4GTj74LwSM/kNMucjrSFf EXtSKukOV1dRO9JG6AOtKnlVIHYTtrva55Voq3OIGpZeodTV39qvdSH9OZIhvo+VFr5Y dMA0/KGLDzbi3SuXBzyW6bX/kihIGCQMYp5LSZE8RJwYcWkkTmMj1Z0DuvPQelnhrPfu S1sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=k46e9uXxihG+jQfepToA8x6gQvaNcSd2eVQ3abDuc3E=; b=WsJmr8xAiwghrEOmYyH07eSl/NsTveVO4fUQ/mM1LBs73E+rYH8/zpOt53fAguxjl2 7Zu6MT/XJcQKGFn+8Aw7ykIcuB2CeDM2yvAAlyx+AsW5k1KUS7f4Rw1zQtczbAxcz8g4 phu5I2cL+Lkog+1dN08/pjeBGOwo91o8Og8vDc2mF4YVz14yjSGHEGrrcVPRBmuQjvDf biR8fSglYyp12UduBEvlIJ3s4wOCKW9cb5UkFVuen+IHjcWQttFLKriPm4sh5Y06uRqp WieMI7g+kBVuBu3Y5kSxOE4UQyF6aXGOxaUzRLBZlAFvv2UPtYk9DU6IOitnpZ85cMvi fyAQ== X-Gm-Message-State: AJcUukcaS4oCSfnqM6iDqhTOuzSujNXHrhMkSGdwfMr/iudMFMEy17oL BEcV7DJewISuCW/wqQyLW2qjoLxk X-Google-Smtp-Source: ALg8bN48DdSbhb+2sZvg63Ki9cyvGpTq4SSUMhV+6KuMAFDQc0bVFlQwlprpdXwb7bQq7UkGLZUX0A== X-Received: by 2002:aca:2807:: with SMTP id 7mr712636oix.7.1548324068398; Thu, 24 Jan 2019 02:01:08 -0800 (PST) Received: from [192.168.1.10] (ip70-171-116-89.no.no.cox.net. [70.171.116.89]) by smtp.googlemail.com with ESMTPSA id m2sm9044126otp.34.2019.01.24.02.01.07 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Jan 2019 02:01:07 -0800 (PST) Subject: Re: Need a command to take the backup of the child tables along with its master table. To: pgsql-general@lists.postgresql.org References: From: Ron Message-ID: <51c5a384-4dc5-fd75-62e6-bcbc518dcfc4@gmail.com> Date: Thu, 24 Jan 2019 04:01:06 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------8C1167F0DFC49869F10B4167" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------8C1167F0DFC49869F10B4167 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 1/24/19 3:40 AM, Raghavendra Rao J S V wrote: > Hi All, > > We have one master table and multiple child tables (dependent tables)  > associated with it. > > While taking the backup of the master table , I would like to take the > backup of all its child (dependent) tables backup also. > > Please guide me how to take the backup of the  master table and its > dependent tables using *pg_dump *command. > Do you know the list of dependent tables?  If so, you can list them in the "pg_dump --table=" clause. If not, you'll have to do some bash magic in parsing the "Foreign-key constraints:" clause of "\d your_table_name" and stuff them in the "pg_dump --table=" clause. -- Angular momentum makes the world go 'round. --------------8C1167F0DFC49869F10B4167 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit On 1/24/19 3:40 AM, Raghavendra Rao J S V wrote:
Hi All,

We have one master table and multiple child tables (dependent tables)  associated with it.

 

While taking the backup of the master table , I would like to take the backup of all its child (dependent) tables backup also.

 

Please guide me how to take the backup of the  master table and its dependent tables using pg_dump command.


Do you know the list of dependent tables?  If so, you can list them in the "pg_dump --table=" clause.

If not, you'll have to do some bash magic in parsing the "Foreign-key constraints:" clause of "\d your_table_name" and stuff them in the "pg_dump --table=" clause.


--
Angular momentum makes the world go 'round.
--------------8C1167F0DFC49869F10B4167--