1

The following is working as expected.

Sending server:

mysqldump db_name tbl_name -d | nc -l 1234

Receiving server:

nc 10.10.10.114 1234 | mysql -uroot -proot@123 test

When I am dumping to remote server, it takes a lot of time to transfer data. Is it possible to add tar jcf - and tar jxf - in this process.

sysadmin1138
  • 133,124
  • 18
  • 176
  • 300
shantanuo
  • 3,579
  • 8
  • 49
  • 66

2 Answers2

2

Sure:

mysqldump db_name tbl_name -d | bzip2 -c | nc -l 1234

and

nc 101010.114 1234 | bzip2 -cd | mysql -uroot -proot@123 test

(Replace bzip2 with gzip or some other compression program if you want; they all work much the same way in Linux)

There's no reason to use tar; you're just dumping data out of MySQL as a single chunk of text. You're also using nc in what is generally considered a "backwards" way; typically the consumer of the data (mysql in this case) does the listening (but there's no actual difference in operation, it just "feels" weird).

Be warned, though, this method might not actually make anything go faster -- in my experience, the bottleneck in MySQL dumps/loads is MySQL, not the network (unless you're running this over a seriously bandwidth-constrained link).

womble
  • 96,255
  • 29
  • 175
  • 230
0

Piping through tar should work just fine.

Sending:

... | tar -cjf - | ...

Receiving

... | tar -xjf - | ...

You might want to use "z" instead as it uses gzip compression instead of the more expensive bzip2, but it depends on how fast it works for you.

sysadmin1138
  • 133,124
  • 18
  • 176
  • 300