Skip to content

Instantly share code, notes, and snippets.

@lennyjpg
Last active December 7, 2018 11:34
Show Gist options
  • Save lennyjpg/5350782 to your computer and use it in GitHub Desktop.
Save lennyjpg/5350782 to your computer and use it in GitHub Desktop.
backup mysqldump over ssh tunnel into gpg
#! /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