Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rS9Ib-00BhNz-48 for pgsql-general@arkaria.postgresql.org; Tue, 23 Jan 2024 05:26:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rS9IX-009iBa-Hr for pgsql-general@arkaria.postgresql.org; Tue, 23 Jan 2024 05:26:09 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rS9IV-009iBS-T6 for pgsql-general@lists.postgresql.org; Tue, 23 Jan 2024 05:26:09 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rS9IQ-002uKg-QG for pgsql-general@lists.postgresql.org; Tue, 23 Jan 2024 05:26:06 +0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailout.nyi.internal (Postfix) with ESMTP id 9DCF35C0322; Tue, 23 Jan 2024 00:26:00 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Tue, 23 Jan 2024 00:26:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1705987560; x=1706073960; bh=u3bwvuex7YOptD5mCw4T1twKhvetms42s5fQLKpa8y4=; b= pns+UrQAks5GVyvX+QguND5YWUEMEHcbbInxTqyvYreWXJH/MoOJPAor9hyhI8Ev CSoQ+Pn8Ci/4o17W921zcqMDVQvxc6DYY5k3+8fY+kzRXHZXcwx5YbVP8nYaD1t4 l0i4wydbLIlYUgHNeTMHJvUJfE821WBCCzP9sGnBglS8sVSvVS186xO6wo0q+Tca jUHMW/t6Z4m/mDSAFgt6DqJhmUm8ANT1I+1fRyv2qAv6+d1gqcgAgTk51OW/eEyh 6PGoknq2AzxMSjnE5w336VHCykZpln5r0yzWN5PXSTtZKYxOu2t+FujqZbzjL1Xu etAVXkgrChoD8OpFOeUR2g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1705987560; x= 1706073960; bh=u3bwvuex7YOptD5mCw4T1twKhvetms42s5fQLKpa8y4=; b=M Muonu+cH8thD9bv4G1LbEpWYo+l4nXlyWXIZURbA2eiTIF/fM3e3jnOTEGq/bx/F 4esGqTSRQUQwkTeYZEMVE7tNOuT9drpRa6ih72upltTgkVPNBdbFLfPSudoNH3/m COrT6Xhjyiu0Y7l8SzBoT9THyTZvNzLyUmzNvmL7XW35hGtW0EY4QsKZi5EIKihP a9NqdXXRxffkmajxA/Re83Q78vUAQAPhIXNV8IdlRArhziT5HFObEU4h4UOIA+4E 1c7CJ3vqUWX5aA0oJ1IERhud6Bnw4C3E48fMonasKJE+o2rL8RRe/wrYmbqPoXrc MugFyJzZ9/rhrAaEeJJrA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdekjedgkedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefkffggfgfuvfhfhfgjtgfgsehtje ertddtvdejnecuhfhrohhmpeetughrihgrnhcumfhlrghvvghruceorggurhhirghnrdhk lhgrvhgvrhesrghklhgrvhgvrhdrtghomheqnecuggftrfgrthhtvghrnhepkeefheduvd ejiefgieefjedtudduffelvdefleehfedtieffuefgvdekleegtddvnecuffhomhgrihhn pehpohhsthhgrhgvshhqlhdrohhrghenucevlhhushhtvghrufhiiigvpedtnecurfgrrh grmhepmhgrihhlfhhrohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgt ohhm X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 23 Jan 2024 00:25:59 -0500 (EST) Message-ID: <17ee71d1-036f-4c4d-a1ff-eb5d1f23a68e@aklaver.com> Date: Mon, 22 Jan 2024 21:25:58 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Backup certain months old data To: Siraj G , pgsql-general@lists.postgresql.org References: Content-Language: en-US From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 1/22/24 19:11, Siraj G wrote: > Hello! > > I would like to know how we can backup certain months old data from > PgSQL and then delete it. The intent is to backup everything that is > older than 2 quarters to a blob storage and delete it, to improve > performance and reduce billing. 1) Postgres does not track the insert/update times of data, so unless you have fields that track that you will not be able to do that. 2) If you do have a way of telling the times for all the records, are you sure that removing the data on a time basis will be clean enough operation that it will not leave the data in a compromised state? 3) Have you considered partitioning? See here: https://www.postgresql.org/docs/current/ddl-partitioning.html > > Regards > Siraj -- Adrian Klaver adrian.klaver@aklaver.com