Created
April 15, 2014 14:12
-
-
Save bogomolov-dev/10735984 to your computer and use it in GitHub Desktop.
tar & move all directories in my backup folder.
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/sh | |
DATE=`date +%Y-%m-%d` | |
BASEDIR=$1 | |
TARGET=$2 | |
echo "Archiving & compressing all backups in: $BASEDIR" | |
for DIR in "$BASEDIR"/*; do | |
if test -d "$DIR"; then | |
ARCHIVE="$DIR-$DATE.tar.gz" | |
tar -zcf $ARCHIVE $DIR | |
echo "Compresses $DIR" | |
mv $ARCHIVE $TARGET | |
echo "Moved $ARCHIVE to $TARGET" | |
rm -r "$DIR" | |
echo "Deleted $DIR" | |
echo "" | |
fi | |
done | |
echo "EOS" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment