Backup and Restore

No matter how stable and robust a system is, it cannot guarantee that there will be no failure. In order to prevent data loss, regular backups are required. YMatrix provides mxbackup and mxrestore tools to implement backup and recovery of clusters.

1 mxbackup

1.1 mxbackup Common Parameter List

Parameters Description
--dbname Backup database
--backup-dir Dir directory for storing backup files
--metadata-only Back up only metadata (DDL), not data in table
--data-only In contrast to --metadata-only, only backup data
--jobs The number of tasks during parallel backup, increasing this value can increase parallelism
--include-table Specify the table to be backed up, the format is \<schema-name>.\<table-name>, and multiple tables can be specified.

Notes!
For details on the use of mxbackup tool, please refer to mxbackup

1.2 Backup Example

The basic usage is as follows:

mxbackup --dbname test --backup-dir /home/mxadmin/backup

Notes!
mxbackup does not provide database connection parameters, so it must be executed on the Master node and logged in with a password-free account. Please configure the PGHOST, PGUSER, and PGPORT environment variables before logging in.

After executing the above command, let’s take a look at the contents of the file in the directory. The file levels of the backup directory are as follows:

mxseg{node number}/backups/{date}/{date + timestamp}

The backup data is in this directory.

The node number Master is -1, and the Segment starts from 0. If there are multiple nodes on the host, there are multiple mxseg{node number} directories.

2 mxrestore

mxrestore is used to restore backup data generated with mxbackup. The usage is as follows:

mxrestore --backup-dir /home/mxadmin/backup --timestamp 20210820143820

--backup-dir specifies the backup directory, consistent with mxbackup

--timestamp specifies the timestamp of the backup, which is the directory name of the {date + timestamp} level in the backup directory, because multiple backups may exist.

After executing the above command, the database will be restored.

Notes!
For details on the use of the mxrestore tool, please refer to mxrestore