Created
May 2, 2013 09:57
-
-
Save manarth/5501271 to your computer and use it in GitHub Desktop.
Dumb DB backup script.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Store backup in this directory: | |
dir="/home/xxx/database_backups/" | |
# Backups will be stored in the pattern $filename-date-time.sql.gz | |
filename="dbbackup.myblog.com" | |
# Database to backup | |
db=blog | |
################################# | |
# Bash script to dump the blog database, zip it, and move it to /home/xxx/database_backups. | |
date=`date +%Y%m%d` | |
time=`date +%H%M%S` | |
filename=$filename-$date-$time.sql | |
mysqldump -C $db > /tmp/$filename | |
gzip /tmp/$filename | |
mv /tmp/$filename.gz $dir | |
# symlink current.sql.gz | |
rm -f $dir/current.sql.gz | |
ln -s $dir/$filename.gz $dir/current.sql.gz | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment