migrating_mariadb_database_from_lxc_to_docker
This is an old revision of the document!
Table of Contents
Migrating MariaDB Database from LXC to Docker
Steps
1. Backup the Database from LXC Instance
- Connect to the LXC instance running MariaDB (in this example,
api.facundoitest.space) and create a backup usingmysqldump. Replacefacundowith your username andVeeamReportswith your database name:
mysqldump -u facundo -p VeeamReports > veeamreports.bak
- This command creates a backup file named
veeamreports.bakin the current directory.
2. Copy the Backup to Docker Host
- From your local machine or the LXC instance, use
scpto transfer the backup file to the Docker host (e.g.,racknerd-vpn.facundoitest.space):
scp ./veeamreports.bak [email protected]:/home/facundo/sql-migration/
- This will place the file in
/home/facundo/sql-migration/on the Docker host.
3. Ensure Backup File Availability in Docker Container
- First, enter the Docker container to confirm the backup file’s location:
docker exec -it mariadb /bin/bash
- Alternative Methods:
- Copy the File Directly into the Container:
docker cp /home/facundo/sql-migration/veeamreports.bak mariadb:/veeamreports.bak
- Mount the Directory During Container Startup (to persist the folder as
/backupin the container):
docker run -d --name mariadb -v /home/facundo/sql-migration:/backup mariadb
4. Import the Backup File to MariaDB in Docker
- With the backup file accessible in the container, import it into the MariaDB instance by connecting to the container:
docker exec -it mariadb /bin/bash
- Run the following command to import the database.
VeeamReportsis the database name andfacundothe user:
mariadb -u facundo -p VeeamReports < veeamreports.bak
5. Verify the Import
- Confirm that the database imported successfully by connecting to MariaDB and checking for tables in
VeeamReports:
mariadb -u facundo -p SHOW TABLES IN VeeamReports;
Notes
- Permissions: Ensure
facundohas the necessary permissions on both the source and destination databases. - Container Access: If
mariadbis not recognized, trymysqlor confirm the correct executable name for MariaDB in your setup.
migrating_mariadb_database_from_lxc_to_docker.1730521697.txt.gz · Last modified: 2024/11/02 04:28 by oso
