Last active
August 29, 2015 14:06
-
-
Save tskrynnyk/6cd51e6a623dcc87e30f to your computer and use it in GitHub Desktop.
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 | |
| # | |
| LC_ALL=C | |
| #DIR_SRC=/var/www/squid-reports | |
| DIR_SRC=/mnt/arch/squid-reports | |
| DIR_DSC=/mnt/arch/squid-reports | |
| # ------------------------------------------------------------------------------ | |
| # Daily | |
| cd ${DIR_SRC}/daily | |
| for y in 2011; do | |
| for m in $(seq -w 12); do | |
| my=$(date --date="$y-$m-01" +%b%Y) | |
| for d in `ls -d *${my}-* 2>/dev/null`; do | |
| if [ -d "$d" ]; then | |
| DIR_BACKUP="${DIR_DSC}/${y}/Daily/Daily-${my}" | |
| [ -d "${DIR_BACKUP}" ] || mkdir -p $DIR_BACKUP | |
| mv -v $d $DIR_BACKUP | |
| fi | |
| done | |
| cd ${DIR_DSC}/${y}/Daily | |
| for i in `ls -d */ 2>/dev/null`; do | |
| if [ -d "$i" ]; then | |
| DIR=`basename $i /` | |
| echo $DIR | |
| (tar cf - $DIR | bzip2 -f > "$DIR.tar.bz2") && rm -rf $DIR | |
| fi | |
| done | |
| cd - 1>/dev/null | |
| done | |
| done | |
| # ------------------------------------------------------------------------------ | |
| # Weekly | |
| # ------------------------------------------------------------------------------ | |
| # Monthly | |
| # EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment