Line 1... |
Line 1... |
1 |
#!/bin/bash
|
1 |
#!/bin/bash
|
2 |
# $Id: alcasar-archive.sh 1300 2014-01-14 22:26:14Z richard $
|
2 |
# $Id: alcasar-archive.sh 1303 2014-01-15 18:03:47Z 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 58... |
Line 58... |
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/tracability.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.log-$NOW.gz
|
63 |
mv $(echo $(ls -rt $DIR_LOG/firewall/tracability.log*.gz | tail -n 1 -)) $DIR_TMP/tracability-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.log-$NOW.tar;
|
72 |
find . -mtime -7 -name 'nfcapd.[0-9]*' | xargs tar -cf $DIR_TMP/tracability-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 115... |
Line 115... |
115 |
;;
|
115 |
;;
|
116 |
--live | -l)
|
116 |
--live | -l)
|
117 |
mkdir -p /tmp/live
|
117 |
mkdir -p /tmp/live
|
118 |
gap=$(($(date +%d)-1))
|
118 |
gap=$(($(date +%d)-1))
|
119 |
cd /var/log/nfsen/profiles-data/live/ipt_netflow
|
119 |
cd /var/log/nfsen/profiles-data/live/ipt_netflow
|
120 |
find . -mtime -$gap -name 'nfcapd.[0-9]*' | xargs tar -cf /tmp/live/tracability.log-$NOW.tar;
|
120 |
find . -mtime -$gap -name 'nfcapd.[0-9]*' | xargs tar -cf /tmp/live/tracability-ALL-$NOW.tar;
|
- |
|
121 |
/usr/local/sbin/alcasar-mysql.sh --dump
|
121 |
cp $(echo $(ls -rt $DIR_BASE/radius-*.sql | tail -n 1 -)) /tmp/live/
|
122 |
mv $(echo $(ls -rt $DIR_BASE/radius-*.sql | tail -n 1 -)) /tmp/live/
|
122 |
cp /var/log/firewall/tracability.log /tmp/live/
|
123 |
cp /var/log/firewall/tracability.log /tmp/live/tracability-HTTP-$NOW.log
|
123 |
tar -czf $DIR_ARCHIVE/tracability-$NOW.tar.gz /tmp/live/*
|
124 |
tar -czf $DIR_ARCHIVE/tracability-$NOW.tar.gz /tmp/live/*
|
124 |
rm -rf /tmp/live
|
125 |
rm -rf /tmp/live
|
125 |
;;
|
126 |
;;
|
126 |
--update | -u)
|
127 |
--update | -u)
|
127 |
# Mise à niveau de l'architecture d'export/archivage
|
128 |
# Mise à niveau de l'architecture d'export/archivage
|