Backup Your Metric Insights Instance
The mi-app-backup script is used to create a backups of your MetricInsights 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.
See Restore Your Metric Insights Instance for information about this complimentary process.
You will need root privileges to do the following commands. So either sign in as root, or do each command prefixed with "sudo".
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:
This will create a backup tarball saved to
/opt/mi/backups/ which is accessible from the host.
The file name will be something like
NOTE: The backup file name includes the hostname, the version of Metric Insights, and the datetime for when the backup was created.
For Version 6 forward:
- You need to run the backup command inside the Web container ( run
mi-consoleon the host to enter the Web container)
- By default, the backup tarball is saved to /opt/mi/backup unless otherwise specified. This /opt/mi/backup directory is accessible on the host (/opt/mi/backup is mounted as a volume inside the Web container).
To see all backup creation options, check the help for the utility:
usage: mi-app-backup [-h] [--dry-run] [--verbose] [--version] [--user USER]
[--password PASSWORD] [--format FORMAT] [--overwrite]
[--ssh-key SSH_KEY] [--include TYPE] [--keep N[d|w|m]]
Backup restore-able Metric Insights data to the given DEST_URI.
DEST_URI destination to store backup file. This can point to a directory
(filename auto-generated) or an exact filename. If omitted file:///var/backups/mi-app-backups/
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
--version, -V show program's version number and exit
--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 the following additions
%v - the MI version being backed up
%h - the hostname of the MI server
%t - the 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
--keep N[d|w|m], -k N[d|w|m]
# of backups / how long to keep backups. 3 will keep the last 3 backups.
3d/w/m will keep backups newer than 3 days/weeks/months ago.
If empty or negative, all backups will be kept.
write to the default backup location: /var/backups/mi-app-backups/
write to the remote machine machine.example.com. This will use the ~/.ssh/id_rsa
ssh key by default if it exists. Use -i SSH_KEY to modify this.
mi-app-backup -u <user> -p <pass> ftp://ftp.example.com/upload/backups[/my_file.tar.gz]
write to an autogenerated file and ftp to ftp.example.com in the /upload/backups
mi-app-backup -u <S3_ID> -p <S3_KEY> s3://my-bucket
write to the Amazon s3 storage. You will need to install s3 on this machine (apt-get install s3cmd). And optionally provide s3 configuration (e.g., <S3_ID>, <S3_KEY> in file .s3cfg)
mi-app-backup -I db
backup database only
only keep the last 2 backups