Subversion Repositories ALCASAR

Rev

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

Rev 1157 Rev 1247
Line 1... Line 1...
1
#!/bin/bash
1
#!/bin/bash
2
# $Id: alcasar-archive.sh 1157 2013-07-16 10:48:11Z stephane $
2
# $Id: alcasar-archive.sh 1247 2013-10-15 16:33:13Z crox53 $
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 52... Line 52...
52
	find . \( -mtime -7 -o -ctime 0 \) -a \( -name '*log-*.gz' \) -exec gpg --output $DIR_ARCHIVE/$file/{}.gpg --encrypt --recipient $GPG_USER {} \;
52
	find . \( -mtime -7 -o -ctime 0 \) -a \( -name '*log-*.gz' \) -exec gpg --output $DIR_ARCHIVE/$file/{}.gpg --encrypt --recipient $GPG_USER {} \;
53
} # end function crypt
53
} # end function crypt
54
 
54
 
55
function archive() {
55
function archive() {
56
		mkdir -p $DIR_ARCHIVE
56
		mkdir -p $DIR_ARCHIVE
57
		mkdir -p $DIR_TMP
57
		mkdir -p $DIR_TMP 
58
		cp $(echo $(ls -rt $DIR_LOG/firewall/tracability.log*.gz | tail -n 1 -)) $DIR_TMP/
58
		mv $(echo $(ls -rt $DIR_LOG/firewall/tracability.log*.gz | tail -n 1 -)) $DIR_TMP/tracability-HTTP.log-$NOW.gz
59
		cp $(echo $(ls -rt $DIR_BASE/radius-*.sql | tail -n 1 -)) $DIR_TMP/
59
		mv $(echo $(ls -rt $DIR_BASE/radius-*.sql | tail -n 1 -)) $DIR_TMP/
-
 
60
		cd /var/log/nfsen/profiles-data/live/ipt_netflow
-
 
61
		find . -mtime 0 -mtime -7 -name 'nfcapd.[0-9]*' | xargs tar -cf $DIR_TMP/tracability-ALL.log-$NOW.tar;
-
 
62
		cd /tmp/
60
		tar cvzf /tmp/$FILE $DIR_TMP/*
63
		tar cvzf /tmp/$FILE archive-$NOW/*
61
} # end archive
64
} # end archive
62
 
65
 
63
#  Core script
66
#  Core script
64
case $args in
67
case $args in
65
	-\? | -h* | --h*)
68
	-\? | -h* | --h*)
Line 90... Line 93...
90
		}
93
		}
91
		fi
94
		fi
92
		rm -rf /tmp/archive-*
95
		rm -rf /tmp/archive-*
93
		chown root:apache $DIR_ARCHIVE/*
96
		chown root:apache $DIR_ARCHIVE/*
94
		;;
97
		;;
-
 
98
	--live | -l)
-
 
99
		mkdir -p /tmp/live 
-
 
100
		gap=$(($(date +%d)-1))
-
 
101
		cd /var/log/nfsen/profiles-data/live/ipt_netflow
-
 
102
		find . -mtime 0 -mtime -$gap -name 'nfcapd.[0-9]*' | xargs tar -cf /tmp/live/tracability.log-$NOW.tar;
-
 
103
		cp $(echo $(ls -rt $DIR_BASE/radius-*.sql | tail -n 1 -)) /tmp/live/
-
 
104
		cp /var/log/firewall/tracability.log /tmp/live/
-
 
105
		tar -czf $DIR_ARCHIVE/tracability-$NOW.tar.gz /tmp/live/*
-
 
106
		rm -rf /tmp/live
-
 
107
		;;
95
	--update | -u)
108
	--update | -u)
96
	#	Mise à niveau de l'architecture d'export/archivage
109
	#	Mise à niveau de l'architecture d'export/archivage
97
		[ -d /tmp/save ] || mkdir -p /tmp/save
110
		[ -d /tmp/save ] || mkdir -p /tmp/save
98
		[ -d $DIR_ARCHIVE/ ] || mkdir -p $DIR_ARCHIVE/	# utile une seule fois mais crée le répertoire si nécessaire
111
		[ -d $DIR_ARCHIVE/ ] || mkdir -p $DIR_ARCHIVE/	# utile une seule fois mais crée le répertoire si nécessaire
99
		;;
112
		;;