Skip to content

Backup and restore

Backup and restore is an essential feature to guarantee the SLAs of your service. STACKIT’s MariaDB offers backup and restore capabilities to help you achieve this goal. These are the features of the backup and restore capabilities:

  • Backup and in-place-restore of your instances
  • Automated scheduled backups every 4 hours
  • Create manual backups
  • Download your backups
  • Backup retention for 14 days
  • All settings are accessible via the Portal, the CLI, Cloud Foundry and Terraform

STACKIT’s MariaDB automatically creates a backup every 4 hours. These backups are held for 14 days. If you want a longer backup history, you need to download the created backups.

You don’t pay for the backup itself, but for the storage the generated backup files reserve. The storage size depends on your backup settings and on the accumulated instance databases size. At the moment, you need to estimate the storage need by yourself.

SettingDescriptionOptions
Encryption keyDefines the key with which the STACKIT system encrypts the backupcustom string

You can get an overview of all existing backups.

You can view all backups by navigating to the Backups tab at the service dashboard of your instance.

  1. Open your project in the STACKIT Portal.

  2. Navigate to Databases > MariaDB.

  3. Select your MariaDB instance and go to Overview.

  4. On the pane on the left, select Backups.

  5. You see a list of all backups with their properties:

    ID, Start time, End time, Backup size, Backup status, Restore created at

    If you created an encryption key prior to the start time of a backup, you are able to download it via the three-dots-menu on the right of the entry.

You can create an encryption key to be able to download your backups.

To create an encryption key, follow the steps below. You need to store the key in a safe place.

  1. Open your project in the STACKIT Portal.
  2. Navigate to Databases > MariaDB.
  3. Select your MariaDB instance and go to Overview.
  4. On the pane on the left, click on Backups.
  5. On the top bar, click on Create encryption key.
  6. Enter an encryption key with a minimum length of 8 characters and click on Create.

You can trigger a manual backup any time.

You can trigger a manual backup in the backup overview pane.

  1. Open your project in the STACKIT Portal.
  2. Navigate to Databases > MariaDB.
  3. Select your MariaDB instance and go to Backups.
  4. Click on Create manual backup.
  5. In the popup dialog, click on Create.
  6. Wait, until the status of the backup is set to Done.

You can trigger a manual backup any time.

You can download a backup in the backup overview pane.

  1. Open your project in the STACKIT Portal.
  2. Navigate to Databases > MariaDB.
  3. Select your MariaDB instance and go to Backups.
  4. Choose a backup to download and click on the three-dots-menu.
  5. Click on Download. If there is no Download option, then the backup was created without encryption. Always Create an encryption key before inserting important data into your instance.
  6. Wait until the download finishes.

You can restore a specific backup to the same instance. To restore your backup to a new instance, download the backup and restore it manually after creating a new instance.

You can perform a restore by navigating to the Backups tab at your instance’s service dashboard and using the Restore button.

  1. Open your project in the STACKIT Portal.

  2. Navigate to Databases > MariaDB.

  3. Select your MariaDB instance and go to Backups.

  4. Click on the three-dots-menu of the right side of the backup you want to restore.

  5. Click on Restore.

  6. On the popup dialog, read the warning that all data in your instance gets overwritten.

  7. If this is ok, click on Restore.

You can perform a manual restore by downloading your backup, decrypting it with your encryption key, creating a new target instance and restoring your backup there.

  1. Download the encrypted backup.

    • Open your project in the STACKIT Portal.
    • Navigate to Databases > MariaDB.
    • Select your MariaDB instance and go to Backups.
    • Click on the three-dots-menu on the right side of your desired backup you plan to restore and click on Download.
    • Wait for the download to complete.
  2. Decrypt the downloaded backup.

    • Open a shell and navigate to the folder where you downloaded the backup into.

    • Decrypt and unzip the backup: <encrypted-backup-file> is the placeholder for the downloaded file. <target-backup-file-prefix> is the name of the target file without the file ending. You can freely choose this name according to the limitations of your local file system.

      Terminal window
      cat <encrypted-backup-file> | openssl enc -aes256 -md md5 -d -pass 'pass:<encryption-key>' > <target-backup-file-prefix>.sql.gz
      gzip -d <target-backup-file-prefix>.sql.gz
    • Verify the file: Use the file command to verify the decrypted and uncompressed backup:

      Terminal window
      head <target-backup-file-prefix>.sql

      If everything is correct, you will see something like this:

      /*M!999999\- enable the sandbox mode */
      -- MariaDB dump 10.19 Distrib 10.11.12-MariaDB, for linux-systemd (x86_64)
      --
      -- Host: localhost Database: mad30dc70
      -- ------------------------------------------------------
      -- Server version 10.11.12-MariaDB-log
      /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
      /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
      /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
  3. Spin up a target instance. This article assumes that you already created a new instance. If not, follow Create and manage instances for MariaDB, to create a new instance. Your target instance needs to be empty.

  4. Prepare the backup for the import. The STACKIT system created the backup with the database name of your existing instance. To prepare the backup for the import, you need to replace the database name with the one of your new instance. To get the database name of your new instance, consult Create and manage credentials for MariaDB to get the connection string. Then extract all trailing characters after the last / of your connection string. This is the new database’s name.

    Terminal window
    cat <target-backup-file-prefix>.sql | sed -e 's/<source_database_name>/<target_database_name>/g' > <target-backup-file-prefix>.import.sql
  5. Import the backup. Connect to the database and import the backup. In case of success, the command does not return any output. Read Create and manage credentials for MariaDB to learn how to receive the parameters of your new (target) instance.

    Terminal window
    mysql --host <target_db_host> --port <target_db_port> --user <target_db_user> --database <target_db_name> < <target-backup-file-prefix>.import.sql
  6. Verify. Connect to the new instance and manually verify that your data has been imported. Consult Connect to MariaDB to learn how to connect to an instance.