Created
January 4, 2009 20:51
-
-
Save bmarini/43178 to your computer and use it in GitHub Desktop.
A quick and dirty website 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 | |
# a quick and dirty backup script. | |
# if you have a websites folder and some databases to backup | |
# this script might be a good starting point. | |
# this script assumes you have user named admin. | |
BASE_DIR='/' | |
TARGET_DIR='sites' | |
BACKUP_TIME=`date +%Y%m%d%H%I%S` | |
BACKUP_FILENAME="${BACKUP_TIME}-${TARGET_DIR}" | |
BACKUP_DIR='/home/admin/backups' | |
# Backup the folder | |
echo "Backing up $TARGET_DIR folder ..." | |
tar zcf ${BACKUP_DIR}/${BACKUP_FILENAME}.tar.gz -C $BASE_DIR $TARGET_DIR | |
# Backup the databases, replace database{1,2} with real databases | |
echo "Backing up the databases ..." | |
mysqldump database1 | gzip -c ${BACKUP_DIR}/${BACKUP_TIME}-database1.sql.gz | |
mysqldump database2 | gzip -c ${BACKUP_DIR}/${BACKUP_TIME}-database2.sql.gz | |
chown -R admin:admin $BACKUP_DIR | |
echo "Done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You have a typo on your
BACKUP_TIME
. You have hours twicedate +%Y%m%d%H%I%S
.I think what you want is
date +%Y%m%d%H%M%S
.