Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

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).

share|improve this answer

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.

share|improve this answer
1  
I really don't understand the desire to use tar in this sort of pipeline. There's no actual files involved. –  womble Jul 30 '11 at 11:44
    
# bzip2: Compressed file ends unexpectedly; # error on receiving data –  shantanuo Jul 30 '11 at 11:45
    
@womble Too early in the morning, didn't catch the whole 'lack of file' thing. –  sysadmin1138 Jul 30 '11 at 11:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.