Created
December 17, 2012 21:07
-
-
Save balkian/4322258 to your computer and use it in GitHub Desktop.
Script to copy all the logs with a certain filename (YYY-MM-DD_<name>.log) to a folder for the day, tar.gz the folder and send it to a remote host.
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 | |
tosend="" | |
for i in *.log; do | |
dir=$(echo $i | awk '{split($1,a,"_"); print a[1]}'); | |
if [ ! -d $dir ]; then | |
mkdir $dir; | |
fi; | |
mv $i $dir; | |
tosend="$tosend\n$dir" | |
done | |
for i in $(echo -e $tosend | uniq);do | |
echo Compressing $i | |
tar -zcvf $i.tar.gz $i | |
scp $i.tar.gz user@server | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment