Last active
December 7, 2018 11:34
-
-
Save lennyjpg/5350782 to your computer and use it in GitHub Desktop.
backup mysqldump over ssh tunnel into gpg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
# open tunnel | |
ssh -v -M -f -N -L 3306:localhost:3306 "$1" -S /tmp/ssh-control | |
# dump sql, gzip, encrypt with openssl | |
mysqldump -u root -p"$3" "$2" --host 127.0.0.1 | gzip | openssl aes-256-cbc -salt -out mysqldump.aes -k "$4" | |
# close tunnel | |
ssh -S /tmp/ssh-control -O exit "$1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment