Gzip mysql


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Gzip mysql
# 1  
Old 09-28-2015
Gzip mysql

Hello!

I'm building a script to sync databases. To speedup the script i want to make use of gzip compression.

This one is working:

Code:
echo "Make dump from $ENV"
	ssh $SSH_USER@$SSH_HOST "mysqldump --user=$DB_USER --password=$DB_PASSWORD $DB" | gzip > ./$DB_FILE
	echo "Import to local"
	gzip -dc < ./$DB_FILE | mysql --user=$LOCAL_DB_USER --password=$LOCAL_DB_PASSWORD $LOCAL_DB
	echo "Completed!"

But i want to use gzip the other way around too:

Code:
echo "Make dump from local"
	mysqldump --user=$LOCAL_DB_USER --password=$LOCAL_DB_PASSWORD $LOCAL_DB > $DB_FILE_LOCAL
	echo "Import to $ENV"
	ssh $SSH_USER@$SSH_HOST "mysql --user=$DB_USER --password=$DB_PASSWORD $DB" < ./$DB_FILE_LOCAL
	echo "Completed!"

Can somebody tell me how to do this?
# 2  
Old 09-28-2015
Code:
echo "Make dump from local"
	mysqldump --user=$LOCAL_DB_USER --password=$LOCAL_DB_PASSWORD $LOCAL_DB > $DB_FILE_LOCAL
	echo "Import to $ENV"
	gzip < ./$DB_FILE_LOCAL | ssh -T $SSH_USER@$SSH_HOST "gunzip | mysql --user=$DB_USER --password=$DB_PASSWORD $DB" 
	echo "Completed!"

This User Gave Thanks to Corona688 For This Post:
# 3  
Old 09-28-2015
Awesome tnx!
# 4  
Old 09-28-2015
You may want to use ssh -e none, which turns off escapes. This is because gzip can create an escape character "~" during compression. Transmitting compressed data streams over to another node via ssh, escapes are a concern.
# 5  
Old 09-28-2015
Quote:
Originally Posted by jim mcnamara
You may want to use ssh -e none, which turns off escapes.
I investigated that, it turns out ssh only does that when it allocates a terminal, hence -T to avoid that.
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. UNIX and Linux Applications

MySQL Daemon failed to start - no mysql.sock file

After doing a yum install mysql mysql-server on Fedora 14 I wasn't able to fully install the packages correctly. It installed MySQL 5.1. I was getting the following error when running the: mysql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)... (3 Replies)
Discussion started by: jastanle84
3 Replies

2. UNIX for Advanced & Expert Users

gzip vs pipe gzip: produce different file size

Hi All, I have a random test file: test.txt, size: 146 $ ll test.txt $ 146 test.txt Take 1: $ cat test.txt | gzip > test.txt.gz $ ll test.txt.gz $ 124 test.txt.gz Take 2: $ gzip test.txt $ ll test.txt.gz $ 133 test.txt.gz As you can see, gzipping a file and piping into gzip... (1 Reply)
Discussion started by: hanfresco
1 Replies

3. Shell Programming and Scripting

Gzip help

Hi Experts!! I was creating a zip file in a server which had zip installed in it. I have another server in which zip is not there and i am instructed to make use of gzip to compress files. I would need your help to know the way to create a gzip file. 1) I do the following to create the zip... (5 Replies)
Discussion started by: ganga.dharan
5 Replies

4. Red Hat

MySQL conflicts with mysql-3.23.58-16.RHEL3.1

I am tring to install mysql 5.0 on redhat linux3. In this server mysql 3 is already installed and hence while I install mysql 5 it gives the following error. How I can install mysql 5 with out affect previous installation? bash-2.05b# rpm -i MySQL-server-community-5.0.41-0.rhel3.i386.rpm... (2 Replies)
Discussion started by: johnveslin
2 Replies

5. UNIX for Advanced & Expert Users

mysql would not start: missing mysql.sock

I recently installed mysql-standard-5.0.21-solaris9-sparc-64bit.pkg on a Solaris 9 machine (SunOS 5.9 Generic_118558-19 sun4u sparc SUNW,Ultra-250). The package installation went very smooth, however, starting mysql is a different story. I get the message below everytime I try to start mysql: #... (2 Replies)
Discussion started by: xnightcrawl
2 Replies

6. UNIX for Advanced & Expert Users

MySQL problem >> missing mysql.sock

MySQL on my server is down.... I figured out that the mysqld process isn't running. When I try to run it, it says it can't find mysql.sock Any suggestions? Here's what I can't do: can't be root don't have physical access (do stuff via SSH) reinstall MySQL (need to keep the current MySQL... (8 Replies)
Discussion started by: _hp_
8 Replies
Login or Register to Ask a Question