Skip to content

Instantly share code, notes, and snippets.

@akhiljalagam
Forked from vanjos/NC-MySQLDUMP.sh
Last active October 31, 2019 10:39
Show Gist options
  • Select an option

  • Save akhiljalagam/2ce8b117288a47328f18d4a3f073c0d0 to your computer and use it in GitHub Desktop.

Select an option

Save akhiljalagam/2ce8b117288a47328f18d4a3f073c0d0 to your computer and use it in GitHub Desktop.
Easy way to do a mysqldump and restore using netcat... with and without encryption
#!/bin/bash
#####
# You'll be needing two machines, the target machine and source one (makes sense, right)?
# without encryption
#####
# 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> ]
# with encryption
#####
# On the target machine
nc -l 55555 | openssl enc -d -aes-128-cfb -pass pass:<password> | gzip -d -c | mysql <database name> -u<user> -p<password>
#####
# On the source machine
mysqldump -u<user> -p<password> <database name> | gzip | openssl enc -aes-128-cfb -pass pass:<password> | nc <ip of target server> 55555
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment