Line 1... |
Line 1... |
1 |
#!/bin/bash
|
1 |
#!/bin/bash
|
2 |
# $Id: alcasar-archive.sh 1564 2015-02-09 23:18:36Z richard $
|
2 |
# $Id: alcasar-archive.sh 1583 2015-03-05 08:39:04Z 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 60... |
Line 60... |
60 |
mkdir -p $DIR_TMP
|
60 |
mkdir -p $DIR_TMP
|
61 |
nb_files=`ls $DIR_LOG/firewall/traceability.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/traceability.log*.gz | tail -n 1 -)) $DIR_TMP/traceability-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/alcasar-users-database-*.sql.gz 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/alcasar-users-database-*.sql.gz | tail -n 1 -)) $DIR_TMP/
|
68 |
fi
|
68 |
fi
|
69 |
cd /var/log/nfsen/profiles-data/live/alcasar_netflow
|
69 |
cd /var/log/nfsen/profiles-data/live/alcasar_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/traceability-ALL-$NOW.tar;
|
72 |
find . -mtime -7 -name 'nfcapd.[0-9]*' | xargs tar -cf $DIR_TMP/traceability-ALL-$NOW.tar;
|
Line 118... |
Line 118... |
118 |
mkdir -p /tmp/live
|
118 |
mkdir -p /tmp/live
|
119 |
gap=$(($(date +%e)-1))
|
119 |
gap=$(($(date +%e)-1))
|
120 |
cd /var/log/nfsen/profiles-data/live/alcasar_netflow
|
120 |
cd /var/log/nfsen/profiles-data/live/alcasar_netflow
|
121 |
find . -mtime -$gap -name 'nfcapd.[0-9]*' | xargs tar -cf /tmp/live/traceability-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/alcasar-users-database-*.sql.gz | tail -n 1 -)) /tmp/live/
|
124 |
cp /var/log/firewall/traceability.log /tmp/live/traceability-HTTP-$NOW.log
|
124 |
cp /var/log/firewall/traceability.log /tmp/live/traceability-HTTP-$NOW.log
|
125 |
tar -czf $DIR_ARCHIVE/traceability-$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 |
*)
|