Skip to content

Instantly share code, notes, and snippets.

@dux
Created November 12, 2011 23:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dux/1361289 to your computer and use it in GitHub Desktop.
Save dux/1361289 to your computer and use it in GitHub Desktop.
MYSQL database push to remote server
#!/bin/bash
FILE="${1}.sql"
rm -rf $FILE
echo "Database dump to [${FILE}]"
mysqldump -u root $1 > $FILE
echo "Deleting remote database"
ssh root@178.79.163.176 "rm -rf /var/www/${FILE}"
echo "Database backup upload"
scp $FILE root@178.79.163.176:/var/www
echo "Remote backup import"
ssh root@178.79.163.176 "mysql --user=root --password=XYZ ${1} < /var/www/${FILE}"
echo "Restart NGINX engine"
ssh root@178.79.163.176 "/root/batch/restartx"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment