]> git.somenet.org - root/sysbackup.git/blob - mkbak-etc.sh
GITOLITE.txt
[root/sysbackup.git] / mkbak-etc.sh
1 #!/bin/bash
2 #
3 # Copyright 2011 by Jan Vales <jan@jvales.net> (Someone <someone@somenet.org>)
4 #
5 #    This program is free software: you can redistribute it and/or modify
6 #    it under the terms of the GNU General Public License as published by
7 #    the Free Software Foundation, version 3 of the License.
8 #
9 #    This program is distributed in the hope that it will be useful,
10 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
11 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 #    GNU General Public License for more details.
13 #
14 #    You should have received a copy of the GNU General Public License
15 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 #
17
18 BAKNAME="/root/sysbackup/bak_${HOSTNAME}_etc_`date --rfc-3339=date`.tar.lzo"
19 echo "backup started: ${BAKNAME} ($(date --rfc-3339=seconds))"
20 tar -capf ${BAKNAME} /etc
21 sync
22 echo "Backup done ($(date --rfc-3339=seconds)) - cleaning..."
23
24 chown -R root:root /root/sysbackup/
25 chmod -R 600 /root/sysbackup/
26 chmod -R 700 /root/sysbackup/*.sh
27 find /root/sysbackup -name bak_${HOSTNAME}_etc_\* | sort | head -n-4 | while read line ; do echo "removing: $line"; rm $line; done;
28 du -sch /root/sysbackup/bak_${HOSTNAME}_etc_*
29 du -sh /root/sysbackup/
30
31 echo "Cleanup done - propagating updates"
32 RMCMD="find /root/sysbackup -name bak_${HOSTNAME}_etc_\*"' | sort | head -n-3 | while read line ; do echo "removing: $line"; rm $line; done;'
33 #echo $RMCMD
34
35 if [ "`hostname`" != "srv254" ];then
36   echo "Propagating to 10.10.0.254"
37   ssh 10.10.0.254 $RMCMD
38   scp ${BAKNAME} 10.10.0.254:/root/sysbackup
39 else
40   echo "NOT propagating to 10.10.0.254"
41 fi
42
43 if [ "`hostname`" != "srv253" ];then
44   echo "Propagating to 10.10.0.253"
45   ssh 10.10.0.253 $RMCMD
46   scp ${BAKNAME} 10.10.0.253:/root/sysbackup
47 else
48   echo "NOT propagating to 10.10.0.253"
49 fi