Skip to content

Instantly share code, notes, and snippets.

@nelsonpecora
Created December 13, 2011 18:46
Show Gist options
  • Select an option

  • Save nelsonpecora/1473305 to your computer and use it in GitHub Desktop.

Select an option

Save nelsonpecora/1473305 to your computer and use it in GitHub Desktop.
Quick MySQL & git database backup
#!/bin/bash
# This script should properly dump a mysql db, add, and commit it to git
echo "Please enter database name: "
read db_name
echo "Username: "
read user
echo "Password: "
read -s pass
mysqldump -u $user -p$pass --skip-extended-insert $db_name > $db_name.sql
git add $db_name.sql
git commit -m "database backup, $(date)"
echo "-------------------------------------"
echo "Database backup added to git."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment