The incremental online backup function is to save all data saved in a normally-functioning YMatrix database cluster at a specific point in time according to certain rules to backup data. Backed up data can ensure data integrity and consistency at that specific point in time. In addition, from all files for a given backup, an available YMatrix database cluster can be restored, with the content consistent with the data from the original cluster at a specific point in time.
The incremental online backup function provides a mode for creating incremental backups based on the necessary full backup function.
Full backup will copy the data of the entire database cluster for backup. When creating a full backup, the creation operation has a certain impact on the running database. But the cluster that restores a database from a full backup can be very fast. Incremental backupBased on the data modifications of the original cluster created by the full backup that has been created. Creating incremental backups has little impact on running databases. However, a cluster that restores a database from an incremental backup will be slower than a full backup. In actual use, the two can be used in combination to balance the operational impact on the original database cluster and the speed of recovery from the backup version.
1. Backup file storage
The backup files for incremental online backups are stored on the machine of the original database cluster, and the directory used is /mxarchive_<original database cluster ID>
. This directory is used on each machine to save files backed up from the database segment of this machine. The directory structure of this directory is as follows:
/mxarchive_<Original Cluster ID>
├── 1 (The dbid of the segment in the original cluster)
│ ├── basebackup (Save the basebackup tarball of the original cluster)
│ │ └── <basebackup 版本> (A full backup version)
│ │ └── base.tar (The tarball of the full backup created by pg_basebackup will be base.tar.gz if compression is enabled)
│ ├── wal (Save WAL segment files)
│ ├── history (Save WAL history files)
│ ├── backup (Save the backup files created by pg_basebackup for full backups)
│ └── misc (Save the fragmented WAL segment files generated due to cluster failover/failback)
├── 2
│ └── ... (Structure is like 1)
└── 3
└── ... (Structure is like 1)
2. Version Information Management
The version information of the incremental online backup is saved on the machine where the master of the original database cluster is located, and is saved using the sqlite data file, and its path is /mxarchive_<original database cluster ID>/metadata/mxarchive.db
.
Notes!
When configuring the database cluster to use the incremental online backup function, the cluster needs to be in normal operation. For the operation of the incremental online backup function, you must use the database cluster management usermxadmin
on the machine where the master is located as the user who executes themxarchive
command.
1. Function Initialization
Log in to the machine where the master is located and use the mxadmin
user to run the following command:
$ mxarchive init
The execution results are roughly as follows:
$ mxarchive init
2025-04-09:14:16:12.561 mxarchive_init:mxadmin:iv-ydt9heyeioxjd1u57imv:019030-[INFO]:-Fetch deployment information of cluster: baz8hPk6Rn27YsFrq7pN3E
2025-04-09:14:16:12.565 mxarchive_init:mxadmin:iv-ydt9heyeioxjd1u57imv:019030-[INFO]:-Get cluster meta from ETCD
2025-04-09:14:16:12.570 mxarchive_init:mxadmin:iv-ydt9heyeioxjd1u57imv:019030-[INFO]:-Initialize local archive storage on every host ...
2025-04-09:14:16:12.599 mxarchive_init:mxadmin:iv-ydt9heyeioxjd1u57imv:019030-[INFO]:-Finished initializing local archive storage.
2025-04-09:14:16:14.799 mxarchive_init:mxadmin:iv-ydt9heyeioxjd1u57imv:019030-[INFO]:-Finished mxarchive initialization for database cluster: baz8hPk6Rn27YsFrq7pN3E
2025-04-09:14:16:14.799 mxarchive_init:mxadmin:iv-ydt9heyeioxjd1u57imv:019030-[INFO]:-Please check /mxarchive_baz8hPk6Rn27YsFrq7pN3E on each host for archive local storage.
2025-04-09:14:16:14.799 mxarchive_init:mxadmin:iv-ydt9heyeioxjd1u57imv:019030-[INFO]:-Please restart database cluster to make GUC changes to take effect.
2. Configure the backup file directory
After initialization is completed, each machine in the cluster will appear as the directory where the backup files are stored. The disks that store backup files for different segments can be adjusted according to the disk configuration needs (for example, configure the corresponding segment directory to be symbolic links to the actual stored disk location).
Notes!
After the configuration is completed, the original directory structure needs to be kept unchanged.
3. Restart the cluster
After the backup storage configuration is complete, the database cluster needs to be restarted to make the backup function take effect. Restart the database cluster using mxstop
:
$ mxstop -arf
After restarting, you can see that the backup WAL segment files begin to appear in the wal
directory under each segment directory in the backup directory. Next you can start creating a new version of the backup.
When you create a backup version for the first time, you must create a full backup. The subsequent operations to create a backup version can create a full backup or incremental backup as needed.
Use the following command to create a full backup version:
$ mxarchive backup --type full
In addition, when creating a full backup, if you need to save disk usage of the backup, you can add compression options to the backup.
$ mxarchive backup --type full --compress
The output is roughly as follows:
$ mxarchive backup --type full
2025-04-09:14:17:16.105 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019553-[INFO]:-Fetch meta for cluster baz8hPk6Rn27YsFrq7pN3E
2025-04-09:14:17:16.109 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019553-[INFO]:-Get cluster meta from ETCD
2025-04-09:14:17:16.115 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019553-[INFO]:-Start to generate full version: 20250409_061716
2025-04-09:14:17:16.115 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019553-[INFO]:-Check current size of database cluster ...
2025-04-09:14:17:16.170 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019553-[DEBUG]:-It takes 55.113584ms to query DB size
2025-04-09:14:17:16.170 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019553-[INFO]:-Finished checking database cluster's database size.
2025-04-09:14:17:16.170 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019553-[INFO]:-Start to run pg_basebackup on every shard. This might take some time ...
2025-04-09:14:17:16.170 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019553-[INFO]:-Start to run base backup on all shards ...
2025-04-09:14:17:27.594 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019553-[DEBUG]:-It takes 11.423554784s to run basebackup on every shard
2025-04-09:14:17:27.594 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019553-[INFO]:-Finished running pg_basebackup on every shard.
2025-04-09:14:17:27.594 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019553-[INFO]:-Start to create global restore point: 20250409_061716
2025-04-09:14:17:29.861 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019553-[INFO]:-Finished creating global restore point: 20250409_061716
2025-04-09:14:17:29.862 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019553-[INFO]:-Collecting WAL file names for global restore point: 20250409_061716
2025-04-09:14:17:29.877 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019553-[DEBUG]:-WAL file name for LSN 0/18000100 is 000000010000000000000006
2025-04-09:14:17:29.877 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019553-[DEBUG]:-WAL file name for LSN 0/140000A0 is 000000010000000000000005
2025-04-09:14:17:29.877 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019553-[DEBUG]:-WAL file name for LSN 0/140000A0 is 000000010000000000000005
2025-04-09:14:17:29.877 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019553-[DEBUG]:-WAL file name for LSN 0/140000A0 is 000000010000000000000005
2025-04-09:14:17:29.879 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019553-[DEBUG]:-WAL file name for LSN 0/140000A0 is 000000010000000000000005
2025-04-09:14:17:29.880 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019553-[DEBUG]:-WAL file name for LSN 0/140000A0 is 000000010000000000000005
2025-04-09:14:17:29.883 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019553-[DEBUG]:-WAL file name for LSN 0/140000A0 is 000000010000000000000005
2025-04-09:14:17:29.883 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019553-[INFO]:-Finished collecting WAL file names for global restore point: 20250409_061716
2025-04-09:14:17:29.883 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019553-[INFO]:-Switching WAL segment files for archiving ...
2025-04-09:14:17:33.561 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019553-[DEBUG]:-Returned LSN is 0/18000150 in file 000000010000000000000006 for shard -1
2025-04-09:14:17:33.561 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019553-[DEBUG]:-Returned LSN is 0/140000F0 in file 000000010000000000000005 for shard 0
2025-04-09:14:17:33.561 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019553-[DEBUG]:-Returned LSN is 0/140000F0 in file 000000010000000000000005 for shard 1
2025-04-09:14:17:33.561 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019553-[DEBUG]:-Returned LSN is 0/140000F0 in file 000000010000000000000005 for shard 2
2025-04-09:14:17:33.561 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019553-[DEBUG]:-Returned LSN is 0/140000F0 in file 000000010000000000000005 for shard 3
2025-04-09:14:17:33.562 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019553-[DEBUG]:-Returned LSN is 0/140000F0 in file 000000010000000000000005 for shard 4
2025-04-09:14:17:33.562 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019553-[DEBUG]:-Returned LSN is 0/140000F0 in file 000000010000000000000005 for shard 5
2025-04-09:14:17:33.562 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019553-[INFO]:-Finished switching WAL segment files for archiving.
2025-04-09:14:17:33.562 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019553-[INFO]:-Collecting data needed to be preserved for archiving this version ...
2025-04-09:14:17:36.647 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019553-[INFO]:-Finished collecting data needed to be preserved for archiving this version.
2025-04-09:14:17:36.647 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019553-[INFO]:-Saving version information into metadata storage ...
2025-04-09:14:17:36.651 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019553-[INFO]:-Finished saving version information into metadata storage.
2025-04-09:14:17:36.651 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019553-[INFO]:-Succeed in generating full archive: 20250409_061716
Use the following command to create an incremental backup version:
$ mxarchive backup --type incr
The output is roughly as follows:
$ mxarchive backup --type incr
2025-04-09:14:18:45.666 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019939-[INFO]:-Fetch meta for cluster baz8hPk6Rn27YsFrq7pN3E
2025-04-09:14:18:45.670 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019939-[INFO]:-Get cluster meta from ETCD
2025-04-09:14:18:45.676 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019939-[INFO]:-Start to generate incremental version 20250409_061845
2025-04-09:14:18:45.676 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019939-[INFO]:-Check current size of database cluster ...
2025-04-09:14:18:45.738 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019939-[DEBUG]:-It takes 61.690291ms to query DB size
2025-04-09:14:18:45.738 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019939-[INFO]:-Finished checking database cluster's database size.
2025-04-09:14:18:45.738 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019939-[INFO]:-Check latest full archive version ...
2025-04-09:14:18:45.739 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019939-[DEBUG]:-It takes 907.545µs to find latest basebackup version: 20250409_061716
2025-04-09:14:18:45.739 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019939-[INFO]:-Found latest full archive version: 20250409_061716
2025-04-09:14:18:45.739 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019939-[INFO]:-Start to create global restore point: 20250409_061716
2025-04-09:14:18:45.776 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019939-[INFO]:-Finished creating global restore point: 20250409_061716
2025-04-09:14:18:45.776 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019939-[INFO]:-Collecting WAL file names for global restore point: 20250409_061716
2025-04-09:14:18:45.787 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019939-[DEBUG]:-WAL file name for LSN 0/18000C28 is 000000010000000000000006
2025-04-09:14:18:45.792 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019939-[DEBUG]:-WAL file name for LSN 0/18000AA8 is 000000010000000000000006
2025-04-09:14:18:45.792 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019939-[DEBUG]:-WAL file name for LSN 0/18000CE8 is 000000010000000000000006
2025-04-09:14:18:45.793 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019939-[DEBUG]:-WAL file name for LSN 0/18000B68 is 000000010000000000000006
2025-04-09:14:18:45.793 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019939-[DEBUG]:-WAL file name for LSN 0/18000C28 is 000000010000000000000006
2025-04-09:14:18:45.794 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019939-[DEBUG]:-WAL file name for LSN 0/18000BA8 is 000000010000000000000006
2025-04-09:14:18:45.794 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019939-[DEBUG]:-WAL file name for LSN 0/1C000758 is 000000010000000000000007
2025-04-09:14:18:45.796 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019939-[INFO]:-Finished collecting WAL file names for global restore point: 20250409_061716
2025-04-09:14:18:45.796 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019939-[INFO]:-Switching WAL segment files for archiving ...
2025-04-09:14:18:47.779 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019939-[DEBUG]:-Returned LSN is 0/1C000770 in file 000000010000000000000007 for shard -1
2025-04-09:14:18:47.779 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019939-[DEBUG]:-Returned LSN is 0/18000D38 in file 000000010000000000000006 for shard 0
2025-04-09:14:18:47.779 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019939-[DEBUG]:-Returned LSN is 0/18000C78 in file 000000010000000000000006 for shard 1
2025-04-09:14:18:47.779 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019939-[DEBUG]:-Returned LSN is 0/18000AF8 in file 000000010000000000000006 for shard 2
2025-04-09:14:18:47.779 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019939-[DEBUG]:-Returned LSN is 0/18000BB8 in file 000000010000000000000006 for shard 3
2025-04-09:14:18:47.779 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019939-[DEBUG]:-Returned LSN is 0/18000C78 in file 000000010000000000000006 for shard 4
2025-04-09:14:18:47.779 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019939-[DEBUG]:-Returned LSN is 0/18000BF8 in file 000000010000000000000006 for shard 5
2025-04-09:14:18:47.779 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019939-[INFO]:-Finished switching WAL segment files for archiving.
2025-04-09:14:18:47.779 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019939-[INFO]:-Collecting data needed to be preserved for archiving this version ...
2025-04-09:14:18:50.838 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019939-[INFO]:-Finished collecting data needed to be preserved for archiving this version.
2025-04-09:14:18:50.838 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019939-[INFO]:-Saving version information into metadata storage ...
2025-04-09:14:18:50.842 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019939-[INFO]:-Finished saving version information into metadata storage.
2025-04-09:14:18:50.842 mxarchive_backup:mxadmin:iv-ydt9heyeioxjd1u57imv:019939-[INFO]:-Succeed in generating incremental archive: 20250409_061845 based on full archive: 20250409_061716
After creating the backup version, you can check which backup versions are currently available. The version number of the backup version is a string represented by a timestamp. Use the following command to view the current version:
$ mxarchive list
The output is roughly as follows:
$ mxarchive list
2025-04-09:14:19:44.752 mxarchive_list:mxadmin:iv-ydt9heyeioxjd1u57imv:020147-[INFO]:-Fetch deployment information of cluster: baz8hPk6Rn27YsFrq7pN3E
2025-04-09:14:19:44.757 mxarchive_list:mxadmin:iv-ydt9heyeioxjd1u57imv:020147-[INFO]:-Get cluster meta from ETCD
2025-04-09:14:19:44.765 mxarchive_list:mxadmin:iv-ydt9heyeioxjd1u57imv:020147-[INFO]:-|
version | base backup version | type | start at
20250409_061716 | 20250409_061716 | full | 2025-04-09 14:17:16
20250409_061845 | 20250409_061716 | incr | 2025-04-09 14:18:45
If you need to see more information, you can add the --detail
parameter.
$ mxarchive list --detail
The output is roughly as follows:
$ mxarchive list --detail
2025-04-09:14:20:15.514 mxarchive_list:mxadmin:iv-ydt9heyeioxjd1u57imv:020322-[INFO]:-Fetch deployment information of cluster: baz8hPk6Rn27YsFrq7pN3E
2025-04-09:14:20:15.519 mxarchive_list:mxadmin:iv-ydt9heyeioxjd1u57imv:020322-[INFO]:-Get cluster meta from ETCD
2025-04-09:14:20:15.529 mxarchive_list:mxadmin:iv-ydt9heyeioxjd1u57imv:020322-[INFO]:-|
version | base backup version | type | start at | end until | base backup size | WAl size | archive size | DB size
20250409_061716 | 20250409_061716 | full | 2025-04-09 14:17:16 | 2025-04-09 14:17:36 | 322 MB | 940 MB | 1.3 GB | 308 MB
20250409_061845 | 20250409_061716 | incr | 2025-04-09 14:18:45 | 2025-04-09 14:18:50 | 322 MB | 1.4 GB | 1.7 GB | 311 MB
This operation does not require the original database cluster to be in operation.
After creating a backup version, you can restore a database cluster from either backup version. The specific operation steps are as follows:
1. Initialize the data directory
Before starting the recovery, you need to prepare the data directory structure for the restored database cluster. Use the following command to create the necessary directory structure on each machine in the cluster:
Notes!
This command operation changes from version 6.3.X: Theversion
parameter is added to the 6.4.X version to specify the backup version to be restored.$ mxarchive reactivate init <version>
The output is roughly as follows:
$ mxarchive reactivate init 20250409_061845 2025-04-09:14:21:11.301 mxarchive_reactivate_init:mxadmin:iv-ydt9heyeioxjd1u57imv:020483-[INFO]:-Fetch deployment information of cluster baz8hPk6Rn27YsFrq7pN3E 2025-04-09:14:21:11.305 mxarchive_reactivate_init:mxadmin:iv-ydt9heyeioxjd1u57imv:020483-[INFO]:-Get cluster meta from ETCD 2025-04-09:14:21:11.310 mxarchive_reactivate_init:mxadmin:iv-ydt9heyeioxjd1u57imv:020483-[INFO]:-Initialize local archive reactivation storage on every host ... 2025-04-09:14:21:11.341 mxarchive_reactivate_init:mxadmin:iv-ydt9heyeioxjd1u57imv:020483-[INFO]:-Finished mxarchive reactivation initialization, and the root directory for data directory is: /mxdata_20250409142111
Here, a data directory that will be used for cluster recovery will be output, which needs to be recorded.
2. Configure the data directory
If you need to configure different disk storage for different segments, you can use a method similar to "Configure Backup File Directory" in a cluster configuration to adjust the disk location where the files in the directory are finally saved. Also need to be noted:
Notes!
After the configuration is completed, the original directory structure needs to be kept unchanged.
3. Cluster Recovery
After the data directory configuration is complete, a new database cluster can be restored from one version. Use the following commands to do it:
$ mxarchive reactivate <version> \
--data-dir <data directory recorded at initialization> \
--port-base <The starting tcp port that can be used for the new cluster>
Notes!
The specified port fromport-base
toport-base + Number of data shards
needs to be not occupied by other applications on all machines.
The output is roughly as follows:
$ mxarchive reactivate 20250409_061845 --data-dir /mxdata_20250409142111 --port-base 8000
2025-04-09:14:22:40.772 mxarchive_reactivate:mxadmin:iv-ydt9heyeioxjd1u57imv:020750-[INFO]:-Fetch deployment information of cluster baz8hPk6Rn27YsFrq7pN3E
2025-04-09:14:22:40.776 mxarchive_reactivate:mxadmin:iv-ydt9heyeioxjd1u57imv:020750-[INFO]:-Get cluster meta from ETCD
2025-04-09:14:22:40.781 mxarchive_reactivate:mxadmin:iv-ydt9heyeioxjd1u57imv:020750-[INFO]:-Query metadata for version 20250409_061845
2025-04-09:14:22:40.783 mxarchive_reactivate:mxadmin:iv-ydt9heyeioxjd1u57imv:020750-[VERBOSE]:-It takes 1.9975ms to query metadata for version 20250409_061845
2025-04-09:14:22:40.783 mxarchive_reactivate:mxadmin:iv-ydt9heyeioxjd1u57imv:020750-[INFO]:-Copy data of version 20250409_061845 from archive storage to new reactivation directory /mxdata_20250409142111
2025-04-09:14:22:50.121 mxarchive_reactivate:mxadmin:iv-ydt9heyeioxjd1u57imv:020750-[VERBOSE]:-It takes 9.337559569s to copy data to new reactivation directory for every shard
2025-04-09:14:22:50.121 mxarchive_reactivate:mxadmin:iv-ydt9heyeioxjd1u57imv:020750-[INFO]:-Try to only activated master ...
2025-04-09:14:22:51.726 mxarchive_reactivate:mxadmin:iv-ydt9heyeioxjd1u57imv:020750-[INFO]:-Start rewriting gp_segment_configuration ...
2025-04-09:14:22:51.734 mxarchive_reactivate:mxadmin:iv-ydt9heyeioxjd1u57imv:020750-[INFO]:-Stop activated master ...
2025-04-09:14:22:56.216 mxarchive_reactivate:mxadmin:iv-ydt9heyeioxjd1u57imv:020750-[INFO]:-Start to setup activated database ...
2025-04-09:14:23:02.867 mxarchive_reactivate:mxadmin:iv-ydt9heyeioxjd1u57imv:020750-[INFO]:-It takes 22.085693839s in total to reactivate a new database from archive version 20250409_061845
At this time, you can connect to the new database cluster through psql to view its contents:
$ psql postgres -p 8000
psql (12.12)
Type "help" for help.
postgres=# select * from gp_segment_configuration;
dbid | content | role | preferred_role | mode | status | port | hostname | address | datadir
-----+-----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1 | -1 | p | p | n | u | 8000 | iv-ydt9heyeioxjd1u57imv | iv-ydt9heyeioxjd1u57imv | /mxdata_20250409142111/master/mxseg-1
6 | 0 | p | p | n | u | 8001 | iv-ydt9heyeiowh2yp2bv0q | iv-ydt9heyeiowh2yp2bv0q | /mxdata_20250409142111/primary/mxseg0
7 | 1 | p | p | n | u | 8002 | iv-ydt9heyeiowh2yp2bv0q | iv-ydt9heyeiowh2yp2bv0q | /mxdata_20250409142111/primary/mxseg1
4 | 2 | p | p | n | u | 8003 | iv-ydt9heyeio5i3z3meox2 | iv-ydt9heyeio5i3z3meox2 | /mxdata_20250409142111/primary/mxseg2
5 | 3 | p | p | n | u | 8004 | iv-ydt9heyeio5i3z3meox2 | iv-ydt9heyeio5i3z3meox2 | /mxdata_20250409142111/primary/mxseg3
2 | 4 | p | p | n | u | 8005 | iv-ydt9heyeioxjd1u57imv | iv-ydt9heyeioxjd1u57imv | /mxdata_20250409142111/primary/mxseg4
3 | 5 | p | p | n | u | 8006 | iv-ydt9heyeioxjd1u57imv | iv-ydt9heyeioxjd1u57imv | /mxdata_20250409142111/primary/mxseg5
(7 rows)
This operation does not require the original database cluster to be in operation.
When a certain version is no longer needed to be restored, it can be deleted from the backup. Use the following command to delete:
$ mxarchive delete <version to be deleted>
The output is roughly as follows:
$ mxarchive delete 20250409_062624
2025-04-09:14:28:00.505 mxarchive_delete:mxadmin:iv-ydt9heyeioxjd1u57imv:022489-[INFO]:-Start to delete archive versions: [20250409_062624]
2025-04-09:14:28:00.506 mxarchive_delete:mxadmin:iv-ydt9heyeioxjd1u57imv:022489-[INFO]:-Are you sure to delete archive versions: [20250409_062624]? [y|N]
y
2025-04-09:14:28:02.337 mxarchive_delete:mxadmin:iv-ydt9heyeioxjd1u57imv:022489-[INFO]:-User confirmed to delete archive versions: [20250409_062624]
2025-04-09:14:28:02.337 mxarchive_delete:mxadmin:iv-ydt9heyeioxjd1u57imv:022489-[INFO]:-Fetch deployment information of cluster: baz8hPk6Rn27YsFrq7pN3E
2025-04-09:14:28:02.342 mxarchive_delete:mxadmin:iv-ydt9heyeioxjd1u57imv:022489-[INFO]:-Get cluster meta from ETCD
2025-04-09:14:28:02.347 mxarchive_delete:mxadmin:iv-ydt9heyeioxjd1u57imv:022489-[INFO]:-Fetch metadata information of cluster's archive: baz8hPk6Rn27YsFrq7pN3E
2025-04-09:14:28:02.349 mxarchive_delete:mxadmin:iv-ydt9heyeioxjd1u57imv:022489-[INFO]:-Finished fetching metadata information of cluster's archive.
2025-04-09:14:28:02.349 mxarchive_delete:mxadmin:iv-ydt9heyeioxjd1u57imv:022489-[INFO]:-Start to delete version information from metadata: [20250409_062624]
2025-04-09:14:28:02.352 mxarchive_delete:mxadmin:iv-ydt9heyeioxjd1u57imv:022489-[INFO]:-Deleted information of version: 20250409_062624
2025-04-09:14:28:02.352 mxarchive_delete:mxadmin:iv-ydt9heyeioxjd1u57imv:022489-[INFO]:-Finished deleting version information from metadata.
2025-04-09:14:28:02.352 mxarchive_delete:mxadmin:iv-ydt9heyeioxjd1u57imv:022489-[INFO]:-Check basebackups that might need to be cleanup ...
2025-04-09:14:28:02.352 mxarchive_delete:mxadmin:iv-ydt9heyeioxjd1u57imv:022489-[INFO]:-Finished checking basebackups that need to be cleanup.
2025-04-09:14:28:02.352 mxarchive_delete:mxadmin:iv-ydt9heyeioxjd1u57imv:022489-[INFO]:-No basebackup need to be deleted.
2025-04-09:14:28:02.352 mxarchive_delete:mxadmin:iv-ydt9heyeioxjd1u57imv:022489-[INFO]:-Start to check WAL files that might need to be deleted ...
2025-04-09:14:28:02.353 mxarchive_delete:mxadmin:iv-ydt9heyeioxjd1u57imv:022489-[INFO]:-Finished checking WAL files that need to be deleted.
2025-04-09:14:28:02.353 mxarchive_delete:mxadmin:iv-ydt9heyeioxjd1u57imv:022489-[INFO]:-Delete WAL files of each segment until given position:
2025-04-09:14:28:02.353 mxarchive_delete:mxadmin:iv-ydt9heyeioxjd1u57imv:022489-[INFO]:-Shard ID: -1 / WAL Segment File: 000000010000000000000005
2025-04-09:14:28:02.353 mxarchive_delete:mxadmin:iv-ydt9heyeioxjd1u57imv:022489-[INFO]:-Shard ID: 0 / WAL Segment File: 000000010000000000000004
2025-04-09:14:28:02.353 mxarchive_delete:mxadmin:iv-ydt9heyeioxjd1u57imv:022489-[INFO]:-Shard ID: 1 / WAL Segment File: 000000010000000000000004
2025-04-09:14:28:02.353 mxarchive_delete:mxadmin:iv-ydt9heyeioxjd1u57imv:022489-[INFO]:-Shard ID: 2 / WAL Segment File: 000000010000000000000004
2025-04-09:14:28:02.353 mxarchive_delete:mxadmin:iv-ydt9heyeioxjd1u57imv:022489-[INFO]:-Shard ID: 3 / WAL Segment File: 000000010000000000000004
2025-04-09:14:28:02.353 mxarchive_delete:mxadmin:iv-ydt9heyeioxjd1u57imv:022489-[INFO]:-Shard ID: 4 / WAL Segment File: 000000010000000000000004
2025-04-09:14:28:02.353 mxarchive_delete:mxadmin:iv-ydt9heyeioxjd1u57imv:022489-[INFO]:-Shard ID: 5 / WAL Segment File: 000000010000000000000004
2025-04-09:14:28:02.400 mxarchive_delete:mxadmin:iv-ydt9heyeioxjd1u57imv:022489-[INFO]:-Finished deleting WAL files of each segment.
Notes!
The Delete command deletes backup files that are no longer needed by any other backup version every time it is executed. To save backup disk space, please delete the backup version that does not need to be restored as much as possible.
If you want to delete multiple versions, you can specify it in the same command:
$ mxarchive delete <version_1 to be deleted> <version_2 to be deleted> <...>
There are the following usage restrictions for using v6.4.X version, which will be improved in subsequent versions.
CREATE TABLESPACE
or DROP TABLESPACE
, neither the incremental version nor the subsequent incremental version will be properly restored.