Add function to return backup_label and tablespace_map

From: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Add function to return backup_label and tablespace_map
Date: 2022-07-07 16:43:49
Message-ID: 38bd5ea4-0b06-5404-cccf-250a7649ddfb@oss.nttdata.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Since an exclusive backup method was dropped in v15, in v15 or later, we need to create backup_label and tablespace_map files from the result of pg_backup_stop() when taking a base backup using low level backup API. One issue when doing this is that; there is no simple way to create those files from two columns "labelfile" and "spcmapfile" that pg_backup_stop() returns if we execute it via psql. Probaby we need to store those columns in a temporary file and run some OS commands or script to separate that file into backup_label and tablespace_map. This is not simple way, and which would prevent users from migrating their backup scripts using psql from an exclusive backup method to non-exclusive one, I'm afraid.

To enable us to do that more easily, how about adding the pg_backup_label() function that returns backup_label and tablespace_map? I'm thinking to make this function available just after pg_backup_start() finishes, also even after pg_backup_stop() finishes. For example, this function allows us to take a backup using the following psql script file.

------------------------------
SELECT * FROM pg_backup_start('test');
\! cp -a $PGDATA /backup
SELECT * FROM pg_backup_stop();

\pset tuples_only on
\pset format unaligned

\o /backup/data/backup_label
SELECT labelfile FROM pg_backup_label();

\o /backup/data/tablespace_map
SELECT spcmapfile FROM pg_backup_label();
------------------------------

Attached is the WIP patch to add pg_backup_label function. No tests nor docs have been added yet, but if we can successfully reach the consensus for adding the function, I will update the patch.

Thought?

Regards,

--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION

Attachment Content-Type Size
pg_backup_label_v1.patch text/plain 3.3 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Nathan Bossart 2022-07-07 16:49:21 Re: pg_parameter_aclcheck() and trusted extensions
Previous Message Tom Lane 2022-07-07 16:41:00 Re: pg_parameter_aclcheck() and trusted extensions