MySQL Dump for tar.gz with remote without shell access

I am trying to get a dump from MySQL to my local client. This is what I have now:

mysqldump -u $MyUSER -h $MyHOST -p$MyPASS $db | gunzip -9 > $FILE

I want it to be .tar.gz, not gunzip archive. I have shell access on the local client, but not on the server. So, I can not make remote tar and copy it here. So, there is a way to connect gzip to tar.gz. (Currently .gz is not recognized as a tarball.)

Thanks.

+4
source share
4 answers

If you issue the above command on the client side, your compression is performed on the client side. mysqldump connects a remote server and downloads data without any compression.

 mysqldump -u $MyUSER -h $MyHOST -p$MyPASS $db > filename tar cfz filename.tar.gz filename rm filename 

Perhaps some unix gurus will have one liner to do this.

+7
source

No. Files (yes, the plural, since tar is commonly used for multiple files) are first put into the tar archive and then compressed. If you are trying to use the tar command-line tool, then you need to save the result in a temporary file, and then tar.

Personally, however, I'd rather hit the other side with cluebat.

+3
source

mysqldump -u $MyUSER -h $MyHOST -p$MyPASS $db | tar -zcvf $FILE -

Where $ FILE is your filename.tar.gz file

+3
source

Archived backup and renaming by time and date:

 /usr/bin/mysqldump -u $MyUSER -h $MyHOST -p$MyPASS $db | gzip -c > /home/backup_`/bin/date +"\%Y-\%m-\%d_\%H:\%M"`.gz 
+1
source

Source: https://habr.com/ru/post/1337251/


All Articles