Skip to content

Instantly share code, notes, and snippets.

@janzikan
Last active November 22, 2015 01:27
Show Gist options
  • Save janzikan/9016378 to your computer and use it in GitHub Desktop.
Save janzikan/9016378 to your computer and use it in GitHub Desktop.
Backup MySQL databases
#!/bin/bash
cd [backup_folder]
today=`date +%Y-%m-%d`
filename="mysql/mysql-$today.sql"
# Backup all databases
# mysqldump -u [username] -p[password] --all-databases > $filename
# Backup listed databases
mysqldump -u [username] -p[password] --databases [db1] [db2] > $filename
# Sync backup file to another folder
rsync -a --inplace $filename [sync_folder]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment