Skip to content

Restoring MySQL backups

Like general backups MySQL backups can be restored across environments by developers with access. This can be useful for when an environment needs to be reset to a specific state, moved across environments or if a point-in-time record needs to be created. Do note that you can't run restores on one MySQL database simultaneously (while there is another backup/restore operation already running on it).

Usage

MySQL backups can be restored to an environment easily.

Step 1: Find the Backup ID you wish to restore:

$ skpr mysql backup list stg
 ─────────── ─────────────────── ──────────── ─────────────────────── ─────────────────────── ────────── ────────────────────
  BACKUP ID   NAME                PHASE        START TIME              COMPLETION TIME         DURATION   DATABASE
 ─────────── ─────────────────── ──────────── ─────────────────────── ─────────────────────── ────────── ────────────────────
  stg-jq7wc   stg-jq7wc-default   Completed    20 Apr 24 08:42 +0000   20 Apr 24 08:45 +0000   3m 0s      drupal-stg-default
 ─────────── ─────────────────── ──────────── ─────────────────────── ─────────────────────── ────────── ────────────────────

Step 2: Create the restore using the backup Backup ID as input:

$ skpr mysql restore create stg stg-8slgf private
Creating new restore
stg-mkrbp

Step 3: Verify the restore was created (optional)

Note that this step will also provide you with details on the start time, how long the process took and what the completion phase was.

$ skpr mysql restore list stg
 ──────────── ─────────────────── ─────────── ─────────── ─────────────────────── ─────────────────────── ────────── ────────────────────
  RESTORE ID   NAME                BACKUP ID   PHASE       START TIME              COMPLETION TIME         DURATION   DATABASE
 ──────────── ─────────────────── ─────────── ─────────── ─────────────────────── ─────────────────────── ────────── ────────────────────
  stg-mkrbp    stg-mkrbp-private   stg-jq7wc   Completed   20 Apr 24 09:53 +0000   20 Apr 24 09:53 +0000   3s         default
 ──────────── ─────────────────── ─────────── ─────────── ─────────────────────── ─────────────────────── ────────── ────────────────────

More Information

$ skpr mysql restore create --help
usage: skpr mysql restore create [<flags>] [<environment>] [<backup>] [<database-name>]

Create an restore on demand

Flags:
      --help  Show context-sensitive help (also try --help-long and --help-man).
  -w, --wait  Wait for restore to complete

Args:
  [<environment>]    Environment to restore
  [<backup>]         Name of the backup to use
  [<database-name>]  Name of the Database to restore from the backup

Database Name (<database-name>)

Argument <database-name> refers to the name of the database

What's next?

After restoring a backup, consider one of the following: