Subversion Repositories ALCASAR

Rev

Rev 1308 | Rev 1400 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 1308 Rev 1358
Line 1... Line 1...
1
#!/bin/bash
1
#!/bin/bash
2
# $Id: alcasar-archive.sh 1308 2014-01-22 22:23:54Z richard $
2
# $Id: alcasar-archive.sh 1358 2014-05-23 12:26:25Z richard $
3
 
3
 
4
# alcasar-archive.sh
4
# alcasar-archive.sh
5
# by Franck BOUIJOUX and REXY
5
# by Franck BOUIJOUX and REXY
6
# This script is distributed under the Gnu General Public License (GPL)
6
# This script is distributed under the Gnu General Public License (GPL)
7
 
7
 
Line 56... Line 56...
56
} # end function crypt
56
} # end function crypt
57
 
57
 
58
function archive() {
58
function archive() {
59
		mkdir -p $DIR_ARCHIVE
59
		mkdir -p $DIR_ARCHIVE
60
		mkdir -p $DIR_TMP 
60
		mkdir -p $DIR_TMP 
61
		nb_files=`ls $DIR_LOG/firewall/tracability.log*.gz 2>/dev/null | wc -w`
61
		nb_files=`ls $DIR_LOG/firewall/traceability.log*.gz 2>/dev/null | wc -w`
62
		if [ $nb_files -ne 0 ]; then
62
		if [ $nb_files -ne 0 ]; then
63
			mv $(echo $(ls -rt $DIR_LOG/firewall/tracability.log*.gz | tail -n 1 -)) $DIR_TMP/tracability-HTTP-$NOW.gz
63
			mv $(echo $(ls -rt $DIR_LOG/firewall/traceability.log*.gz | tail -n 1 -)) $DIR_TMP/traceability-HTTP-$NOW.gz
64
		fi
64
		fi
65
		nb_files=`ls $DIR_BASE/radius-*.sql 2>/dev/null | wc -w`
65
		nb_files=`ls $DIR_BASE/radius-*.sql 2>/dev/null | wc -w`
66
		if [ $nb_files -ne 0 ]; then
66
		if [ $nb_files -ne 0 ]; then
67
			mv $(echo $(ls -rt $DIR_BASE/radius-*.sql | tail -n 1 -)) $DIR_TMP/
67
			mv $(echo $(ls -rt $DIR_BASE/radius-*.sql | tail -n 1 -)) $DIR_TMP/
68
		fi
68
		fi
69
		cd /var/log/nfsen/profiles-data/live/ipt_netflow
69
		cd /var/log/nfsen/profiles-data/live/ipt_netflow
70
		nb_files=`find . -mtime -7 -name 'nfcapd.[0-9]*' | wc -l`
70
		nb_files=`find . -mtime -7 -name 'nfcapd.[0-9]*' | wc -l`
71
		if [ $nb_files -ne 0 ]; then
71
		if [ $nb_files -ne 0 ]; then
72
			find .  -mtime -7 -name 'nfcapd.[0-9]*' | xargs tar -cf $DIR_TMP/tracability-ALL-$NOW.tar;
72
			find .  -mtime -7 -name 'nfcapd.[0-9]*' | xargs tar -cf $DIR_TMP/traceability-ALL-$NOW.tar;
73
		fi
73
		fi
74
		cd /tmp/
74
		cd /tmp/
75
		nb_files=`ls archive-$NOW/* 2>/dev/null | wc -w`
75
		nb_files=`ls archive-$NOW/* 2>/dev/null | wc -w`
76
		if [ $nb_files -ne 0 ]; then
76
		if [ $nb_files -ne 0 ]; then
77
			tar cvzf /tmp/$FILE archive-$NOW/*
77
			tar cvzf /tmp/$FILE archive-$NOW/*
Line 116... Line 116...
116
	--live | -l)
116
	--live | -l)
117
		mkdir -p $DIR_ARCHIVE
117
		mkdir -p $DIR_ARCHIVE
118
		mkdir -p /tmp/live 
118
		mkdir -p /tmp/live 
119
		gap=$(($(date +%d)-1))
119
		gap=$(($(date +%d)-1))
120
		cd /var/log/nfsen/profiles-data/live/ipt_netflow
120
		cd /var/log/nfsen/profiles-data/live/ipt_netflow
121
		find .  -mtime -$gap -name 'nfcapd.[0-9]*' | xargs tar -cf /tmp/live/tracability-ALL-$NOW.tar;
121
		find .  -mtime -$gap -name 'nfcapd.[0-9]*' | xargs tar -cf /tmp/live/traceability-ALL-$NOW.tar;
122
		/usr/local/sbin/alcasar-mysql.sh --dump
122
		/usr/local/sbin/alcasar-mysql.sh --dump
123
		mv $(echo $(ls -rt $DIR_BASE/radius-*.sql | tail -n 1 -)) /tmp/live/
123
		mv $(echo $(ls -rt $DIR_BASE/radius-*.sql | tail -n 1 -)) /tmp/live/
124
		cp /var/log/firewall/tracability.log /tmp/live/tracability-HTTP-$NOW.log
124
		cp /var/log/firewall/traceability.log /tmp/live/traceability-HTTP-$NOW.log
125
		tar -czf $DIR_ARCHIVE/tracability-$NOW.tar.gz /tmp/live/*
125
		tar -czf $DIR_ARCHIVE/traceability-$NOW.tar.gz /tmp/live/*
126
		rm -rf /tmp/live
126
		rm -rf /tmp/live
127
		;;
127
		;;
128
	*)
128
	*)
129
		echo "Unknown argument :$1";
129
		echo "Unknown argument :$1";
130
		echo "$usage"
130
		echo "$usage"