Created
January 6, 2015 22:14
-
-
Save palefailmel/3a9859ae4c0f602867e1 to your computer and use it in GitHub Desktop.
simple backup script that backups some directories, and then saves them in one tarball and copies that one somewhere else.
This file contains hidden or 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 | |
# Author: M. Stevenson | |
# Date : 2015-01-06 | |
# Desc : Backup sites to local directory and put in tarball | |
# remove older backups | |
find ~/backups/* -mtime +30 -exec rm {} \; | |
BDIR=~/backups/ | |
DATE=`date +%Y-%m-%d` | |
# only backup certain sites to save space | |
# leaving out test/play sites | |
SITES=(siteone sitetwo sitethree) | |
for i in ${SITES[@]}; do | |
tar -xcvf ${BDIR}${i}.${DATE}.tar.gz /html/${i} | |
done | |
# remove the old latest grouping | |
rm ${BDIR}latest.tar.gz | |
# now put all of the latest into one single tarball, so it can be moved to wherever | |
tar -zcvf ${BDIR}latest.tar.gz ${BDIR}*.${DATE}.tar.gz | |
# now copy to wherever, in our case we're copying to Dropbox | |
cp ${BDIR}latest.tar.gz ~/Dropbox/ThisIsOurBackupFolder/latest.tar.gz |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment