r/mysql • u/chiezyy • Jan 30 '25
question Transfering 3TB mysql databases to another server
Hey there, so I would like to transfer around 3 to 4 TB of mysql data from my personal server to a cloud mysql server. I cannot create backups as I am lacking harddrive space.
I tried looking for syncronization tools but for a sideproject.. paying 200$ is not really something I would like to do..
I asked chatgpt which usually asked me to create a backup of some form or go with tools which might die during the transfer process which would then result in starting over.
Do you guys have any suggestions?
8
Upvotes
12
u/willjasen Jan 30 '25
you have a relational database in the terabytes and you aren’t willing to spend a couple hundred on a sync tool..? you messed up somewhere
5
u/notAGreatIdeaForName Jan 30 '25
You could set up an innodb cluster and add the cloud instance as a replica, as soon it is synced up you switch the cloud to a master and also switch the app connection to it. After that you remove the source db replica.
7
u/golucky1983 Jan 30 '25
Xtrabackup xbstream
1
u/johannes1234 Jan 30 '25
Use MySQL clone - this is essentially copying the data directory files with a little management around to ensure consistency. Faster isn't really possible.
https://dev.mysql.com/doc/refman/9.2/en/clone-plugin.html
1
u/tantricengineer Jan 31 '25
Why though? A cloud based DB might cost you more in 6 months than just upgrading your local storage and migrating the DB locally.
1
u/lucasjkr Jan 31 '25
I’m just curious what your personal project was that accumulated that much data in 13 years? Any hints
1
u/josfaber Feb 02 '25
Where do you backup?
1
u/FelisCantabrigiensis Feb 02 '25
You can use MySQL Shell which now has a copyInstance function. https://dev.mysql.com/doc/mysql-shell/8.4/en/mysql-shell-utils-copy.html
It does not need local storage to run.
It's quite fast, will easily fill most WAN links.
2
u/NCMarc Jan 31 '25
MySQL Dump > Pipe data into the other server LIKE SO. Make sure the remote server can be accessed from your local machine.
mysqldump -h local_server -u local_user -p local_database \ | mysql -h remote_server -u remote_db_user -p remote_databaseIf you have SSH access on the remote server, you could dump it to that server and import it as well.
1
u/bchambers01961 Jan 30 '25
Unfortunately you’re going to need some extra hdd space however you do it. If it was me I’d use my dumper / my loader.
You could also maybe write a script that moves the selects data into a file and then loads from file into new db.
It also might be worth assessing if you need all the data in your new environment
1
u/kickingtyres Jan 31 '25
At a push, run Mysqldump over SSH tunnel straight into the new DB, or even open the DB port for the duration of the copy.
mysqldump -u -p -hlocalhost | mysql -u -p -h[cloudServer]
Might take a day or so :D.Or break it down into individual schema or tables within the DB and do it in batches over a few days
1
u/lampministrator Jan 31 '25
You can create an ssh tunnel to your dev server, mount it and save the file directly to the "mounted" drive. You need to make sure you have persistence on your tunnel so the pipe doesn't break. And 3TB will take some time, so make sure you have a stable connection
1
u/datasleek Feb 01 '25
Can you archive some of the data first? Export data you won’t need, compress and export to S3. Get an external HD, they are cheap.
1
u/sreekanth850 Feb 01 '25
Replication is the way to go.