Skip to content

Instantly share code, notes, and snippets.

@Dare-NZ
Last active December 17, 2015 00:49
Show Gist options
  • Save Dare-NZ/5523584 to your computer and use it in GitHub Desktop.
Save Dare-NZ/5523584 to your computer and use it in GitHub Desktop.
Some SSH functions for backing up a MYSQL DB, zipping it and shipping it off to a remote server.
// Obviously {this} means replace with your version of this
// Dump DB
mysqldump -p -u {username} {dbname} > {dbname.sql}
// Tar DB
tar -cvf {dbname.tar} {dbname.sql}
// Move DB
curl -T {dbname.tar} ftp://{remote path}/{dbname.sql} --user {username}:{password} -v
// Remove leftovers
rm {dbname.sql}
rm {dbname.tar}
// If you want to install on the remote server
tar -xvf {dbname.tar}
mysql -u {username} -p {dbname} < {dbname.sql}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment