Created
July 17, 2012 17:56
-
-
Save stanwu/3130846 to your computer and use it in GitHub Desktop.
auto backup folder (if less then 8GB total space)
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 | |
for i in `ls` | |
do | |
#echo "[$i]" | |
if [ -d $i ]; then | |
mysize=`du -d 0 $i | awk '{print $1}'` | |
mydate=`date +%m%d%y` | |
if [ $mysize -lt 8388608 ]; then | |
echo "Pack $i -> $mysize" | |
tar cvzf $i.$mydate.$mysize.tgz $i | |
if [ $? == 0 ]; then | |
echo "OK!" | |
rm -rf $i | |
else | |
echo "Err!" | |
rm $i.$mydate.$mysize.tgz | |
fi | |
else | |
echo "Skip $i -> $mysie (too large)" | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment