Skip to content

Instantly share code, notes, and snippets.

@seanbehan
Created January 19, 2012 17:19
Show Gist options
  • Select an option

  • Save seanbehan/1641297 to your computer and use it in GitHub Desktop.

Select an option

Save seanbehan/1641297 to your computer and use it in GitHub Desktop.
Simple Backup Script
#!/bin/bash
# crontab -e
# 10 3 * * * /root/mysql_backups.sh > ~/backups/status.log
# change DB_USER and DB_PASSWD as per configuration
export DB_BACKUP="~/domains/baks"
export DB_USER="******"
export DB_PASSWD="*****"
export DB_HOST="*****"
echo ""
echo "Backing up all mysql databases"
echo "--------------------------"
echo "* Creating backup..."
mysqldump --user=$DB_USER --password=$DB_PASSWD --all-databases --host=$DB_HOST | bzip2 > ~/data/baks/mysql-`date +%Y-%m`.bz2
echo "----------------------"
echo "Done"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment