Backup and Restore

Even the most stable and robust systems cannot guarantee failure-free operation. To prevent data loss, regular backups are essential. YMatrix provides the mxbackup and mxrestore tools to perform cluster backup and restore operations.

1 mxbackup

1.1 Common mxbackup Parameters

Parameter Description
--dbname Database to back up
--backup-dir Directory for storing backup files
--metadata-only Back up only metadata (DDL), excluding table data
--data-only Opposite of --metadata-only; backs up only data
--jobs Number of parallel tasks during backup; increasing this value improves parallelism
--include-table Specifies tables to back up in the format \<schema-name>.\<table-name>; multiple tables can be specified

Note!
For detailed usage of mxbackup, refer to mxbackup.

1.2 Backup Example

Basic usage:

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

Note!
mxbackup does not support database connection parameters. It must be executed on the Master node using a passwordless account.
Before logging in, configure the PGHOST, PGUSER, and PGPORT environment variables.

After running the above command, examine the contents of the backup directory. The file hierarchy is as follows:

mxseg{segment-id}/backups/{date}/{date+timestamp}

The backup data is stored in this directory.

The segment ID is -1 for the Master, and Segments are numbered starting from 0. If multiple nodes exist on a host, multiple mxseg{segment-id} directories will be present.

2 mxrestore

mxrestore is used to restore backup data generated by mxbackup. Usage example:

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

--backup-dir Specifies the backup directory, same as used in mxbackup.

--timestamp Specifies the backup timestamp, which corresponds to the {date+timestamp} subdirectory name in the backup directory, as multiple backups may exist.

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

Note!
For detailed usage of mxrestore, refer to mxrestore.