Skip to content

Instantly share code, notes, and snippets.

@manarth
Created May 2, 2013 09:57
Show Gist options
  • Save manarth/5501271 to your computer and use it in GitHub Desktop.
Save manarth/5501271 to your computer and use it in GitHub Desktop.
Dumb DB backup script.
#!/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