Skip to content

Instantly share code, notes, and snippets.

@eaydin
Forked from vanjos/NC-MySQLDUMP.sh
Created November 13, 2017 13:03
Show Gist options
  • Save eaydin/d0dfa048a6a9b29c90a9f44a73f48504 to your computer and use it in GitHub Desktop.
Save eaydin/d0dfa048a6a9b29c90a9f44a73f48504 to your computer and use it in GitHub Desktop.
Easy way to do a mysqldump and restore using netcat (this is NOT encrypted)
#####
# You'll be needing two machines, the target machine and source one (makes sense, right)?
#####
# On the target machine
nc -l 55555 | gzip -d -c | mysql <database name> -u<user> -p<password> [ | <decrypt> ]
#####
# On the source machine
mysqldump -u<user> -p<password> <database name> | gzip | nc <ip of target server> 55555 [ | <encrypt> ]
#####
# Adding Encryption...
# Encrypting with openssl
/usr/bin/openssl enc -aes-256-cbc -pass pass:<some_password> -e
# DECRYPTING THE FILE
# /usr/bin/openssl enc -aes-256-cbc -pass pass:<some_password> -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment