Back

Copy MariaDb from One server to another

  • 1
  • Self Hosted
  • Web
ORIZON
21 Mar, 2023, 05:08

Direct container shell

TL;DR
TL;DR: To copy MariaDb from one server to another, make sure to use the same docker-compose.yml and .env files. If you have a 0kb Backup.sql file, try using the command "docker compose exec mariadb sh -c 'exec mysqldump --all-databases --add-drop-database -u"$MYSQL_USER" -p"$MYSQL_PASSWORD"' > ./dump.sql" in the same directory as appwrite's docker-compose.yml to create a dump.sql file for restore. Use the command "docker compose exec -T mariadb sh -c 'exec mysql -u"$MYSQL_USER" -
safwan
21 Mar, 2023, 05:09

do you still have access to the old server?

safwan
21 Mar, 2023, 05:09

and the old db?

ORIZON
21 Mar, 2023, 05:09

Yeah

ORIZON
21 Mar, 2023, 05:09

Yeah

safwan
21 Mar, 2023, 05:09

okay try these commands. I'm not a docker expert, so please bear with me lol

ORIZON
21 Mar, 2023, 05:09

No Problem

safwan
21 Mar, 2023, 05:11

docker compose exec mariadb sh -c 'exec mysqldump --all-databases --add-drop-database -u"$MYSQL_USER" -p"$MYSQL_PASSWORD"' > ./dump.sql

safwan
21 Mar, 2023, 05:12

make sure to run this in the same directory as appwrite's doker-compose.yml

safwan
21 Mar, 2023, 05:12

docker compose exec -T mariadb sh -c 'exec mysql -u"$MYSQL_USER" -p"$MYSQL_PASSWORD"' < dump.sql use this to restore on your other server

ORIZON
21 Mar, 2023, 05:13

Doing now

safwan
21 Mar, 2023, 05:13

let me know

safwan
21 Mar, 2023, 05:13

add a sudo if you're not root

ORIZON
21 Mar, 2023, 05:13

LOCK TABLES _console_webhooks_perms WRITE; /*!40000 ALTER TABLE _console_webhooks_perms DISABLE KEYS /; /!40000 ALTER TABLE _console_webhooks_perms ENABLE KEYS /; UNLOCK TABLES; /!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE /; /!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS /; /!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS /; /!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT /; /!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS /; /!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION /; /!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2023-03-21 5:13:27

safwan
21 Mar, 2023, 05:14

well it seems like it worked?

ORIZON
21 Mar, 2023, 05:14

I got a Backup.sql file but its 0Kb

ORIZON
21 Mar, 2023, 05:14

0 kb

ORIZON
21 Mar, 2023, 05:14

Sorry dump.sql

ORIZON
21 Mar, 2023, 05:14

Is it okay?

safwan
21 Mar, 2023, 05:15

i dont think so

safwan
21 Mar, 2023, 05:16

Try looking at this, along with the comments

safwan
21 Mar, 2023, 05:16

this should be able to help you

ORIZON
21 Mar, 2023, 05:18

now its working. It shows 967kb

Drake
21 Mar, 2023, 06:24

Make sure you're you're using the same docker-compose.yml and .env file from your old server on the new server

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more