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. MatrixDB provides mxbackup and mxrestore tools to implement cluster backup and recovery.

1. mxbackup

1.1 List of commonly used parameters of mxbackup

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.

For detailed usage methods of mxbackup, please refer to Document

1.2 Backup Example

The basic usage is as follows:

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

Note: 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 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{节点号}/backups/{日期}/{日期+时间戳}

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, which is 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.

For detailed usage methods of mxrestore, please refer to Document