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, use the following command from the application server:

mi-app-backup -v

This will create a file similar to:

/var/backups/mi-app-backups/mi-full-backup-20130228-0407.tar.gz

NOTE: The timestamp in the filename can be used to distinguish new and old backup files.

2. Usage

To see all usage options:

mi-app-backup -h

 

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]]

                    [DEST_URI]

Backup restore-able Metric Insights data to the given DEST_URI.

positional arguments:

 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

optional arguments:

 -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.  

3. Examples

Examples:

   mi-app-backup

       write to the default backup location: /var/backups/mi-app-backups/

 

   mi-app-backup /some/dir[/my_file.tar.gz]

 

   mi-app-backup file:///some/dir[/my_file.tar.gz]

 

   mi-app-backup ssh://machine.example.com/home/cru/backups[/my_file.tar.gz]

       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

       directory.

 

   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

 

   mi-app-backup -k2

       only keep the last 2 backups

 

0 Comments

Add your comment

E-Mail me when someone replies to this comment