Backup Your Metric Insights Instance

The mi-app-backup script is used to create a backups of your Metric Insights application and database. This backup tool will create a snapshot of your application database and critical files on the application server. The result of a backup is a tarball that can be used to restore the state of your application on the same or any other machine.

NOTES:

  • You will need root privileges to do the following commands. So either sign in as root, or do each command prefixed with "sudo".
  • Backup process creates a temporary folder:
    • v7.0.1+: /opt/mi/backup/.tmp/
    • v6.4.5: /tmp
  • See Restore Your Metric Insights Instance for information about this complimentary process.
  • Beginning v7.0.1, the backup process can be executed manually via MI Console.

1. Create the Backup File

To create an application backup file, run the mi-app-backup utility from the application server, inside of the Web container. An example command to create a backup using this utility is: 

mi-app-backup -vv

This will create a backup tarball saved to /opt/mi/backup/ which is accessible from the host.

The file name will be something like mi-full-backup-hostname-vX.X.X-202412280215.tar.gz.

  • The backup file name includes the hostname, the version of Metric Insights, and the datetime for when the backup was created.

NOTES:

  1. You need to run the backup command inside the Web container ( run mi-web on the host to enter the Web container)
  2. By default, the backup tarball is saved to /opt/mi/backup unless otherwise specified. This directory is accessible on the host (/opt/mi/backup is mounted as a volume inside the Web container).

2. Usage

To see all backup creation options, run mi-app-backup -h

Positional Parameters
DEST_URI Destination to store backup file. This can point to a directory (filename auto-generated) or an exact filename. If omitted, file:///opt/mi/backup will be used
Backup Options
DEST_URI Destination to store backup file. This can point to a directory (filename auto-generated) or an exact filename. If omitted, file:///opt/mi/backup will be used.
-h, --help Show this help message and exit.
--dry-run, -n Dry run. Print what would happen.
--verbose, -v Be verbose. More v's, more verbose.
--user USER, -u USER Optional user for logging into remote host.
--password PASSWORD, -p PASSWORD Optional password for logging into remote system. Note: for ssh, use --ssh-key below.
--format FORMAT A format string for autogenerated filenames. Format identifiers are the same as time.strftime, with additional options like %v (MI version), %h (hostname), and %t (backup type).
--overwrite, -o Overwrite existing backup file.
--ssh-key SSH_KEY, -i SSH_KEY SSH key file to use for remote server.
--include TYPE, -I TYPE What to include in the backup. Choose from 'db', 'files', or 'full'. Default: full.
--skip-dataset Skip backup of Default MySQL Dataset storage.
--prune, -P Prune unnecessary log tables from backup.
--s3-chunk-size MB S3 upload file chunk size (in MB). Default: 100.
--s3-parallel-connections S3_PARALLEL_CONNECTIONS Number of connections to use when uploading to S3. Default: 4.
--keep N[d|w|m], -k N[d|w|m] Number of backups or duration to keep backups. Example: 3d (3 days), 3w (3 weeks), or 3m (3 months).
--mode MODE, -m MODE Working mode for the backup manager. Options: create, list, delete. Default: create.
--force Force creating backup, ignoring non-critical errors.

3. Examples

Examples of running mi-app-backup script: 

Command Output
mi-app-backup Write to the default backup location: /var/backups/mi-app-backups/
mi-app-backup /some/dir[/my_file.tar.gz] Specify a custom directory or file for the backup.
mi-app-backup file:///some/dir[/my_file.tar.gz] Write to a local directory using the file protocol.
mi-app-backup ssh://machine.example.com/home/cru/backups[/my_file.tar.gz] Write to a remote machine (machine.example.com) using SSH. Defaults to ~/.ssh/id_rsa, or use -i SSH_KEY to specify a different key.
mi-app-backup -u <user> -p <pass> ftp://ftp.example.com/upload/backups[/my_file.tar.gz] Write to an autogenerated file and upload it to the /upload/backups directory on the FTP server ftp.example.com.
mi-app-backup -u <S3_ID> -p <S3_KEY> s3://my-bucket Write to Amazon S3 storage. Requires s3cmd installed and configured (e.g., <S3_ID>, <S3_KEY> in .s3cfg).
mi-app-backup -I db Backup the database only.
mi-app-backup -k2 Keep only the last two backups.