Created
September 16, 2015 11:29
-
-
Save 5c0tt/5feb84d9485131c958de to your computer and use it in GitHub Desktop.
Rotating Folder Backup Script
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 | |
| # Taken from http://triq.net/script/rotating-folder-backup-script | |
| # because the site is slow and down, and I wanted to review this later | |
| # Originally created by zany on Tue, 03/17/2009 - 13:38 | |
| BASEDIR=/home/projects # SET THIS | |
| BAKDIR=/home/backups # SET THIS | |
| stamp=$(date +%Y-%m-%d) | |
| cd "$BASEDIR" | |
| for prj in * ; do | |
| find "$prj" -mtime -1 -type f | grep "" >/dev/null && { | |
| tar cjf "$BAKDIR/${prj}_${stamp}.tar.bz2" "$prj" | |
| find "$BAKDIR" -name "${prj}_*" -mtime -14 -mtime +7 -not -name "*-01.*" -exec rm {} \; | |
| ls -sh "$BAKDIR/${prj}_"* | |
| } | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment