In this tutorial you will learn how to migrate your data from existing MariaDB service instance to a new created.

Requirements

  • cat
  • sed
  • diff
  • openssl
  • gunzip
  • mysql (the command line client for MySQL/MariaDB)

Migration steps

Order and configure a new target service instance

Order a new service instance with the same plan and configuration as your existing service. Create credential key for it.

Trigger manual backup of your source service instance

Open Service Dashboard to manually trigger a backup of your source service instance. Please make sure you set an encryption password. Instructions can be found here.

Download and prepare backup

Download the latest backup of source service instance from Service Dashboard and store it on your local machine.

Use following commands to decrypt, decompress and replace source database name with the target:

cat <downloaded_backup_filename> | openssl enc -aes256 -md md5 -d -pass 'pass:<your_backup_encryption_password>' | gunzip -c > backup.sql
cat backup.sql | sed -e 's/<source_database_name>/<target_database_name>/g' > backup.fork.sql

Examples:
cat 9ff61a4d-e4b8-40fb-a41e-03eb2f0eda61-1654846156752 | openssl enc -aes256 -md md5 -d -pass 'pass:mypassword' | gunzip -c > backup.sql
cat backup.sql | sed -e 's/msd41eb6a/msd521ed3/g' > backup.fork.sql

BASH

Please compare both files after the replacement to make sure that your database data itself has not been changed by 'sed' replacement:

diff <file1> <file2>

Example:
diff backup.sql backup.fork.sql
BASH

Restore backup to target instance

Required parameters can be retrieved from credential key.

mysql --host <target_db_host> --port <target_db_port> --user <target_db_user> --database <target_db_name> < backup.fork.sql

Example:
mysql --host msd521ed3-1.data.eu01.onstackit.cloud --port 49378 --user a9sd56e32f74793ba8aa116db3daabe --database msd521ed3 --password < backup.fork.sql
BASH

Verify restored data

Connect to target service instance using mysql client and check restored data.

mysql --host <target_db_host_name> --port <target_db_port> --user <target_db_user> --database <target_db_name> --password

Example:
mysql --host msd521ed3-1.data.eu01.onstackit.cloud --port 49296 --user a9sd56e32f74793ba8aa116db3daabe --database msd521ed3 --password
BASH


Please find additional information here.

Further Information