Skip to content

Instantly share code, notes, and snippets.

@blu3Alien
Created January 25, 2013 12:04
Show Gist options
  • Save blu3Alien/4633929 to your computer and use it in GitHub Desktop.
Save blu3Alien/4633929 to your computer and use it in GitHub Desktop.
Shell script to restore a supplied compressed mySQL backup. Note: update username and password before using.
#!/bin/sh
doContinue=n
echo -n "Do you really want to continue? [y/n] "
read doContinue
if [ "$doContinue" != "y" ]; then
echo "Quitting..."
exit
fi
if [ ! -r $1 ]; then #file not found or readable
echo "File $1 does not exist or is not readable."
exit
fi
gunzip < $1 | mysql --user=[username] --password=[password]
echo "Databases restored from $1."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment