Skip to content

Instantly share code, notes, and snippets.

@choonkeat
Created December 6, 2008 13:02
Show Gist options
  • Save choonkeat/32869 to your computer and use it in GitHub Desktop.
Save choonkeat/32869 to your computer and use it in GitHub Desktop.
backup cron (backups of last 7 days, last month or any year)
#!/bin/bash
#
# place this file in the directory you want to keep the backup
# mysqldumps. this script lets you retrieve dumps of last 7 days,
# last month or any year
#
BACKUP_DB=app_production
cd `dirname $0`
mysqldump $BACKUP_DB -u root > today.sql && \
gzip -f today.sql && \
cp today.sql.gz "`date +'%G'`".sql.gz && \
cp today.sql.gz "`date +'%b'`".sql.gz && \
cp today.sql.gz "`date +'%a'`".sql.gz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment