3 # Copyright 2011 by Jan Vales <jan@jvales.net> (Someone <someone@somenet.org>)
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.
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.
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/>.
18 BAKNAME="/root/sysbackup/bak_${HOSTNAME}_etc_`date --rfc-3339=date`.tbz2"
19 echo "backup started: ${BAKNAME}"
20 tar -cjpf ${BAKNAME} /etc
22 echo "Backup done - cleaning..."
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-9 | while read line ; do echo "removing: $line"; rm $line; done;
28 du -sch /root/sysbackup/bak_${HOSTNAME}_etc_*
29 du -sh /root/sysbackup/
31 echo "Cleanup done - propagating updates"
32 RMCMD="find /root/sysbackup -name bak_${HOSTNAME}_etc_\*"' | sort | head -n-8 | while read line ; do echo "removing: $line"; rm $line; done;'
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
40 echo "NOT propagating to 10.10.0.254"
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
48 echo "NOT propagating to 10.10.0.253"