1

I make backup over ssh like this:

mysqldump -u dbuser -pXXXXXXXX dbname | ssh -i ~/.ssh/id_rsa_backup backup@my.server.com 'cat > /var/backups/services/my_service/db/$(date +"%Y-%m-%d").sql'

How to send gziped data to save bandwith and disk space ?

3

adding this to ~/.ssh/config ssh will gzip on the fly :)

http://linux.die.net/man/5/ssh_config for more detailed options

Host *
    Compression yes
    # from 1 (fast) to 9 (slow, best). The default level is 6
    # CompressionLevel 9
    # ServerAliveInterval 15
    # ServerAliveCountMax 3
    # KeepAlive yes

Host bak-serv
    Hostname my.server.com
    IdentityFile ~/.ssh/id_rsa_backup
    User backup
    # Port 22

with your command, you get a sql.gz at the end not a plain sql text file.

mysqldump -u dbuser -pXXXXXXXX dbname \
  | gzip | cat | ssh -i ~/.ssh/id_rsa_backup backup@my.server.com \
  'cat > /var/backups/services/my_service/db/$(date +"%Y-%m-%d").sql.gz'

becomes

mysqldump -u dbuser -pXXXXXXXX dbname \
   | ssh bak-serv \
   | gzip -c > /var/backups/services/my_service/db/$(date +"%Y-%m-%d").sql.gz

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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