Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mgGU5-00023e-GP for pgsql-general@arkaria.postgresql.org; Fri, 29 Oct 2021 01:15:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mgGU4-0000tZ-1x for pgsql-general@arkaria.postgresql.org; Fri, 29 Oct 2021 01:15:04 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mgGU3-0000tQ-Hf for pgsql-general@lists.postgresql.org; Fri, 29 Oct 2021 01:15:03 +0000 Received: from mail-qt1-x82f.google.com ([2607:f8b0:4864:20::82f]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mgGTw-0005vB-Jm for pgsql-general@lists.postgresql.org; Fri, 29 Oct 2021 01:15:02 +0000 Received: by mail-qt1-x82f.google.com with SMTP id n2so7682785qta.2 for ; Thu, 28 Oct 2021 18:14:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :references:from:in-reply-to; bh=g13wBAHhQOPB9wR3GMtGMAZ0ZzfUPRcS4C0bnBf1zO4=; b=eVWDof+9YfrDPct3d/n7BHmsSHzI7RaH2SOSl1jTKxozxWVhohb8pQ9GD1eQL2kX9o 3GJqQhNSGlaaOt1qSDOucZB/3TDSi49/SUDjY9MH6AzRfiPAzfdQfO+2ODWZMEuAjnTL QQwyZ+AoXb1OchSXVjMFnoSSTJntBMxzi5cuyPbz1v184U0/S0P0nod3P0hJSCrf0Yer VylkdsnNJPoQ2ivbl3RLYCTqK/FjewTgqMdrWUY6UVyJdr2di2Cdlogm8gAS2eGtEAmP y8iyRRalrvRhRmo6fGdsQcNABrvFy/h7m16EgH928mtMYZJm7fEusO6nrwhyaLeKDje2 te3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to; bh=g13wBAHhQOPB9wR3GMtGMAZ0ZzfUPRcS4C0bnBf1zO4=; b=bhGBoM1SIbzUCnV+WmbvAm9SJEffFgQbYAh3B/dRfI+OBAiN7mSWC3qXKo/K1xUsWI JTyQuvx0YkLZhhBzoApDDcedB9MMF7MKi4EJNc9fZpwx5tchUrnyR0NL2A/aqKV1+4dz 7vJSVpwqM2pTjrcA//zjy7VbgNYYxCHuFqLAaeOOIWCslZYSI+zlkX8yOb9wC3wg4CyQ xTOWeUad1gJu5go/P/Y1XfcVHaYjSoquy7qohLus3ezhUuObhs0JBpPgHvzBw7z6m4wE zc8Y0IL8/SDF0tVy2tG+W4ynw2JZ69Wkxqtv+UQIwRJQ6vBRfKC5HriuFP48UKr2nTY3 r2Fw== X-Gm-Message-State: AOAM530JTzenwq/sot1TmEQ1RV42p6tNhKH9U92GvODvkgqBWZAQZlvO OyPsKRzmyHYIdvrcXwVNYjk+vjEaAgg= X-Google-Smtp-Source: ABdhPJyzYcIF1SRxqHvDWFaBYNe3o/7SOrRXZ9Q2NAN8jgY4DEtr9i6Z71dm+rvx+9YuV6hCuDJeZQ== X-Received: by 2002:a05:622a:15c7:: with SMTP id d7mr8958186qty.203.1635470094890; Thu, 28 Oct 2021 18:14:54 -0700 (PDT) Received: from [192.168.2.100] (pool-72-79-19-93.nwrknj.east.verizon.net. [72.79.19.93]) by smtp.gmail.com with ESMTPSA id n19sm3288850qta.22.2021.10.28.18.14.54 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 28 Oct 2021 18:14:54 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------xKC0vG7jdrCMYEKjZzzEhofB" Message-ID: <3d5f2552-c819-c423-cb37-e190f74ea37f@gmail.com> Date: Thu, 28 Oct 2021 21:14:53 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Subject: Re: Incremental backup Content-Language: en-US To: pgsql-general@lists.postgresql.org References: <4ad9560c-d6f7-3f74-b577-cf72c93195d0@aklaver.com> <68943e88-7d6b-edb3-90b5-782b9fb5fcbd@gmail.com> <57f54e84-c5f2-84fe-6e65-de5f4ddfdd47@aklaver.com> <995bab59-10e3-eaa9-2b93-afb0474595cd@gmail.com> <20211028200853.GA1020@momjian.us> From: Mladen Gogala In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------xKC0vG7jdrCMYEKjZzzEhofB Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 10/28/21 18:07, Andreas Joseph Krogh wrote: > I think everybody agrees that incremental backup /per database/, and > not cluster-wide, is nice, and it would be nice if PG supported it. > But, given the way PG is architectured, having cluster-wide WALs, > that's not an easy task to implement. > Repeating "other databases have it" doesn't change that. > -- > Andreas Joseph Krogh I am not advocating for the database level incremental backups, but all databases that have it also have cluster wide/instance wide WAL logs. Cluster wide WAL logs do not make database level incremental backups hard. Both Oracle and DB2 have database level incremental backups and both have cluster wide WAL (redo or logs). So does SQL*Server which is a bit specific because its log is used for both recovery, as WAL, and undo so its very different from Postgres. Also, SQL Server is, to my knowledge, the only database which doesn't use MVCC. The technology that all of those databases employ is a bitmap device which has one bit per each database block. Full backups set all bits to 0 and whenever block is modified, the corresponding bit is set to 1. The backup tool in the incremental mode then only copies blocks with the bitmap value of 1. I am not too thrilled by that implementation. In particular, with Oracle there were bugs with database restore, "duplicate database" operation, global cache locks and instance latches. I've had quite a few headaches with RMAN cumulative incremental backups. My preferred method of backup is storage snapshot. Snapshots then can be  backed up to other arrays (NetApp SnapVault, Hitachi HUR, EMC SRDF)  or can be backed up to deduplicated offline storage like AWS Glacier or EMC Data Domain using simple file level utilities. Once snapshot is taken, it is a read-only file system and the files are no longer opened by the database processes. The classic file level backup tools like pg_basebackup or rman are pretty much unusable once your database hits 50 TB or so. With 50TB database, your RTO (Recovery Time Objective) will be in days. You can only push around 3TB/hour down a 10Gbit Ethernet pipe. On the other hand companies like Facebook. Amazon, Walmart or Target are losing hundreds of thousands USD per hour of downtime. Downtime of 15 hours or longer is completely unacceptable. Backup is only the last line of defense. It should only be used if everything else fails. And if you have to use file level tool like pg_basebackup and tar to restore your VLDB, you should also get your resume ready. Incremental backups are awkward and ungainly. You have to restore the full backup and all incrementals taken since the last full. After that, you must apply the remaining WAL files. So, by definition, restoring incremental backup is, by definition, longer than restoring a full backup. So, if you have to take a backup, get yourself a deduplicating backup utility. Deduplication will only save the backup blocks that are different from the previous backup. In other words, you can do a daily full backup with the space expenditure of an incremental backup. Also, if you need backups because of regulatory reasons (HIPAA, SOX), incremental backups will not do. Long story short, there are much more important things to do on Postgres than incremental database level backups. BTW, Chuck Norris can take and incremental database level backup of a Postgres database and recover database without restoring the preceding full backup. I am not sure whether Chuck Norris is a member of Postgres steering committee. -- Mladen Gogala Database Consultant Tel: (347) 321-1217 https://dbwhisperer.wordpress.com --------------xKC0vG7jdrCMYEKjZzzEhofB Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit


On 10/28/21 18:07, Andreas Joseph Krogh wrote:
 
I think everybody agrees that incremental backup per database, and not cluster-wide, is nice, and it would be nice if PG supported it. But, given the way PG is architectured, having cluster-wide WALs, that's not an easy task to implement.
Repeating "other databases have it" doesn't change that.
 
--
Andreas Joseph Krogh

I am not advocating for the database level incremental backups, but all databases that have it also have cluster wide/instance wide WAL logs. Cluster wide WAL logs do not make database level incremental backups hard. Both Oracle and DB2 have database level incremental backups and both have cluster wide WAL (redo or logs). So does SQL*Server which is a bit specific because its log is used for both recovery, as WAL, and undo so its very different from Postgres. Also, SQL Server is, to my knowledge, the only database which doesn't use MVCC.

The technology that all of those databases employ is a bitmap device which has one bit per each database block. Full backups set all bits to 0 and whenever block is modified, the corresponding bit is set to 1. The backup tool in the incremental mode then only copies blocks with the bitmap value of 1. I am not too thrilled by that implementation. In particular, with Oracle there were bugs with database restore, "duplicate database" operation, global cache locks and instance latches. I've had quite a few headaches with RMAN cumulative incremental backups. My preferred method of backup is storage snapshot. Snapshots then can be  backed up to other arrays (NetApp SnapVault, Hitachi HUR, EMC SRDF)  or can be backed up to deduplicated offline storage like AWS Glacier or EMC Data Domain using simple file level utilities. Once snapshot is taken, it is a read-only file system and the files are no longer opened by the database processes.

The classic file level backup tools like pg_basebackup or rman are pretty much unusable once your database hits 50 TB or so. With 50TB database, your RTO (Recovery Time Objective) will be in days. You can only push around 3TB/hour down a 10Gbit Ethernet pipe. On the other hand companies like Facebook. Amazon, Walmart or Target are losing hundreds of thousands USD per hour of downtime. Downtime of 15 hours or longer is completely unacceptable. Backup is only the last line of defense. It should only be used if everything else fails. And if you have to use file level tool like pg_basebackup and tar to restore your VLDB, you should also get your resume ready.

Incremental backups are awkward and ungainly. You have to restore the full backup and all incrementals taken since the last full. After that, you must apply the remaining WAL files. So, by definition, restoring incremental backup is, by definition, longer than restoring a full backup. So, if you have to take a backup, get yourself a deduplicating backup utility. Deduplication will only save the backup blocks that are different from the previous backup. In other words, you can do a daily full backup with the space expenditure of an incremental backup. Also, if you need backups because of regulatory reasons (HIPAA, SOX), incremental backups will not do.

Long story short, there are much more important things to do on Postgres than incremental database level backups. BTW, Chuck Norris can take and incremental database level backup of a Postgres database and recover database without restoring the preceding full backup. I am not sure whether Chuck Norris is a member of Postgres steering committee.

-- 
Mladen Gogala
Database Consultant
Tel: (347) 321-1217
https://dbwhisperer.wordpress.com
--------------xKC0vG7jdrCMYEKjZzzEhofB--