Subversion Repositories ALCASAR

Rev

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

Rev 1596 Rev 1695
Line 1... Line 1...
1
#!/bin/bash
1
#!/bin/bash
2
# $Id: alcasar-archive.sh 1596 2015-03-16 23:07:55Z richard $
2
# $Id: alcasar-archive.sh 1695 2015-09-08 07:37:46Z franck $
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 84... Line 84...
84
	-\? | -h* | --h*)
84
	-\? | -h* | --h*)
85
		echo "$usage"
85
		echo "$usage"
86
		exit 0
86
		exit 0
87
		;;
87
		;;
88
	--clean | -c)	
88
	--clean | -c)	
-
 
89
# Cleanup of files older than 365 days
89
		cleanup
90
		cleanup
90
		;;
91
		;;
91
	--now | -n)
92
	--now | -n)
-
 
93
		
-
 
94
# Cleanup of files older than 365 days
92
		cleanup
95
		cleanup
-
 
96
# make an archive
93
		archive
97
		archive
-
 
98
# Saving of the database
-
 
99
		/usr/local/sbin/alcasar-mysql.sh --dump
-
 
100
# Encryption of the archive
94
 		if [ -e /tmp/$FILE ]; then 
101
 		if [ -e /tmp/$FILE ]; then 
95
			if [ $CRYPT -eq "1" ]; then
102
			if [ $CRYPT -eq "1" ]; then
96
			{
103
			{
97
				# 1 ) chiffrement/signature =1 ==> gpg --encrypt avec test de la clé présente
104
				# 1 ) chiffrement/signature =1 ==> gpg --encrypt avec test de la clé présente
98
				gpg --output $DIR_ARCHIVE/$FILE-crypt.gpg --armor --encrypt --recipient $GPG_USER  /tmp/$FILE
105
				gpg --output $DIR_ARCHIVE/$FILE-crypt.gpg --armor --encrypt --recipient $GPG_USER  /tmp/$FILE
Line 117... Line 124...
117
		mkdir -p $DIR_ARCHIVE
124
		mkdir -p $DIR_ARCHIVE
118
		mkdir -p /tmp/live 
125
		mkdir -p /tmp/live 
119
		gap=$(($(date +%e)-1))
126
		gap=$(($(date +%e)-1))
120
		cd /var/log/nfsen/profiles-data/live/alcasar_netflow
127
		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;
128
		find .  -mtime -$gap -name 'nfcapd.[0-9]*' | xargs tar -cf /tmp/live/traceability-ALL-$NOW.tar;
-
 
129
# Saving of the database
122
		/usr/local/sbin/alcasar-mysql.sh --dump
130
		/usr/local/sbin/alcasar-mysql.sh --dump
123
		mv $(echo $(ls -rt $DIR_BASE/alcasar-users-database-*.sql.gz | tail -n 1 -)) /tmp/live/
131
		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
132
		cp /var/log/firewall/traceability.log /tmp/live/traceability-HTTP-$NOW.log
125
		tar -czf $DIR_ARCHIVE/traceability-$NOW.tar.gz /tmp/live/*
133
		tar -czf $DIR_ARCHIVE/traceability-$NOW.tar.gz /tmp/live/*
126
		rm -rf /tmp/live
134
		rm -rf /tmp/live