1 |
#!/bin/bash |
2 |
|
3 |
cd /root |
4 |
# list of included files to the backup |
5 |
# note we are not including /home/e-smith/{files,shares} and /home/e-smith/db/mysql*/{daily,hourly} |
6 |
# you are responsible to backup and restore them separatly |
7 |
cat <<'EOF' > dir.list |
8 |
/etc/e-smith/templates-custom |
9 |
/etc/e-smith/templates-user-custom |
10 |
/etc/group |
11 |
/etc/gshadow |
12 |
/etc/passwd |
13 |
/etc/samba/secrets.tdb |
14 |
/etc/samba/smbpasswd |
15 |
/etc/shadow |
16 |
/etc/ssh |
17 |
/etc/sudoers |
18 |
/root |
19 |
/home/e-smith/Maildir |
20 |
/home/e-smith/home |
21 |
/home/e-smith/ssl.crt |
22 |
/home/e-smith/ssl.key |
23 |
/home/e-smith/dkim_keys |
24 |
/home/e-smith/db |
25 |
/var/lib/dhcpd/dhcpd.leases |
26 |
/var/log/qpsmtpd |
27 |
/var/log/sqpsmtpd |
28 |
/var/log/qmail |
29 |
/var/log/httpd/ |
30 |
/var/log/dovecot/ |
31 |
/var/log/squid/ |
32 |
/var/log/iptables/ |
33 |
/var/spool/mail/ |
34 |
/var/spool/spamd/ |
35 |
EOF |
36 |
|
37 |
[ -e /etc/smbpasswd ] && cat <<'EOF' >> dir.list |
38 |
/etc/smbpasswd |
39 |
EOF |
40 |
|
41 |
[ -e /var/log/samba/samba_audit ] && cat <<'EOF' >> dir.list |
42 |
/var/log/samba/samba_audit |
43 |
EOF |
44 |
|
45 |
[ -e /var/service/qpsmtpd/config/dkimkeys/ ] && cat <<'EOF' >> dir.list |
46 |
/var/service/qpsmtpd/config/dkimkeys/ |
47 |
EOF |
48 |
|
49 |
## add here inclusion from db key |
50 |
|
51 |
## exclude files |
52 |
cat <<EOF >exclude.list |
53 |
/home/e-smith/db/mysql/daily |
54 |
/home/e-smith/db/mysql/hourly |
55 |
/home/e-smith/db/mysql55/daily |
56 |
/home/e-smith/db/mysql55/hourly |
57 |
/home/e-smith/db/mysql57/daily |
58 |
/home/e-smith/db/mysql57/hourly |
59 |
/home/e-smith/files |
60 |
/home/e-smith/shares |
61 |
/etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/20LoadModule80PHP |
62 |
/etc/e-smith/templates-custom/etc/hosts.allow/sshd |
63 |
/etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/35SSL00Listen443 |
64 |
/etc/e-smith/templates-custom/etc/dhcpd.conf/25DomainNameServers |
65 |
/etc/e-smith/templates-custom/etc/dhcpd.conf/25LeaseTimeDefault |
66 |
/etc/e-smith/templates-custom/etc/dhcpd.conf/25LeaseTimeMax |
67 |
/etc/e-smith/templates-custom/etc/dhcpd.conf/25Routers |
68 |
EOF |
69 |
|
70 |
## add here exclusion from db key |
71 |
|
72 |
# search for local script added |
73 |
find /usr/local/bin/ -type f | xargs -I % sh -c "rpm -qf % 2>&1 > /dev/null || echo % >> dir.list" |
74 |
# search for local dir script added |
75 |
find /usr/local/ -maxdepth 1 -type d | xargs -I % sh -c "rpm -qf % 2>&1 > /dev/null || echo % >> dir.list" |
76 |
# search for cron files not owned by a rpm |
77 |
find /etc/cron.* -type f | xargs -I % sh -c "rpm -qf % 2>&1 > /dev/null || echo % >> dir.list" |
78 |
# search for udev rules not owned by a rpm ! oucl add an option there in case you change of hardware |
79 |
find /etc/udev/rules.d/ -type f | xargs -I % sh -c "rpm -qf % 2>&1 > /dev/null || echo % >> dir.list" |
80 |
# search for spamassassin user created config |
81 |
find /etc/mail/spamassassin -maxdepth 1 -type f | xargs -I % sh -c "rpm -qf % 2>&1 > /dev/null || echo % >> dir.list" |
82 |
|
83 |
################## |
84 |
# |
85 |
# here starts the magic |
86 |
# we backup each known corpm -q smeserver-dovecot ntribs folder |
87 |
# |
88 |
################## |
89 |
#smeserver-awstats.noarch |
90 |
# data will be in /home/e-smith/files/users/admin |
91 |
# we only backup the config files |
92 |
rpm -q smeserver-awstats >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
93 |
/etc/e-smith/web/panels/manager/cgi-bin/.awstats/ |
94 |
EOF |
95 |
# see with Daniel if they have a specific config |
96 |
#rpm -q awstats >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
97 |
#/var/lib/awstats |
98 |
#EOF |
99 |
#for those we assume you handle yourself the backup or the pools in /var/lib/BackupPC |
100 |
rpm -q smeserver-BackupPC >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
101 |
/etc/BackupPC |
102 |
EOF |
103 |
rpm -q smeserver-BackupPC4 >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
104 |
/etc/BackupPC |
105 |
EOF |
106 |
rpm -q smeserver-bandwidthd >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
107 |
/var/www/bandwidthd/ |
108 |
EOF |
109 |
#smeserver-clamav-unofficial-sigs and clamav-unofficial-sigs |
110 |
rpm -q smeserver-clamav-unofficial-sigs >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
111 |
/var/lib/clamav-unofficial-sigs/ |
112 |
EOF |
113 |
#smeserver-dansguardian smeserver-dansguardian-panel |
114 |
rpm -q smeserver-dansguardian >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
115 |
/etc/dansguardian/ |
116 |
EOF |
117 |
#smeserver-denyhosts |
118 |
rpm -q smeserver-denyhosts >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
119 |
/var/lib/denyhosts/ |
120 |
/etc/hosts.deny_ssh |
121 |
/etc/hosts.deny_ssh.purge.bak |
122 |
EOF |
123 |
rpm -q smeserver-dl >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
124 |
/var/lib/dl/ |
125 |
EOF |
126 |
rpm -q dokuwiki >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
127 |
/etc/dokuwiki/acl.auth.php |
128 |
/etc/dokuwiki/acronyms.conf |
129 |
/etc/dokuwiki/entities.conf |
130 |
/etc/dokuwiki/interwiki.conf |
131 |
/etc/dokuwiki/local.php |
132 |
/etc/dokuwiki/plugins.local.php |
133 |
/etc/dokuwiki/scheme.conf |
134 |
/var/lib/dokuwiki/data/attic |
135 |
/var/lib/dokuwiki/data/index |
136 |
/var/lib/dokuwiki/data/media |
137 |
/var/lib/dokuwiki/data/media_attic |
138 |
/var/lib/dokuwiki/data/media_meta |
139 |
/var/lib/dokuwiki/data/meta |
140 |
/var/lib/dokuwiki/data/pages |
141 |
EOF |
142 |
rpm -q dokuwiki >/dev/null 2>&1 && for D in /usr/share/dokuwiki/lib/plugins/*;do |
143 |
rpm -qf $D >/dev/null 2>&1 || echo $D >> dir.list |
144 |
done |
145 |
|
146 |
|
147 |
#rpm -q smeserver-dovecot >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
148 |
[ -e /etc/dovecot/sharemailbox ] && cat <<'EOF' >> dir.list |
149 |
/etc/dovecot/sharemailbox/ |
150 |
EOF |
151 |
|
152 |
#smeserver-durep |
153 |
rpm -q smeserver-durep >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
154 |
/var/lib/durep |
155 |
EOF |
156 |
#smeserver-ezmlm-web |
157 |
rpm -q smeserver-ezmlm-web >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
158 |
/home/e-smith/files/ezmlm |
159 |
EOF |
160 |
[ -e /var/lib/phone ] && cat <<'EOF' >> dir.list |
161 |
/var/lib/phone |
162 |
EOF |
163 |
rpm -q smeserver-freepbx >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
164 |
/opt/freepbx |
165 |
/var/lib/asterisk/ |
166 |
/etc/asterisk |
167 |
/var/spool/asterisk/ |
168 |
/var/log/asterisk |
169 |
/usr/local/sbin/amportal |
170 |
/usr/local/sbin/fwconsole |
171 |
/usr/sbin/amportal |
172 |
/usr/sbin/fwconsole |
173 |
EOF |
174 |
# smeserver-fail2ban |
175 |
if [ -d /etc/fail2ban/action.d ]; then |
176 |
for F in $(ls /etc/fail2ban/action.d/);do |
177 |
rpm -qf /etc/fail2ban/action.d/$F >/dev/null 2>&1 || echo /etc/fail2ban/action.d/$F >> dir.list |
178 |
done |
179 |
fi |
180 |
if [ -d /etc/fail2ban/fail2ban.d ]; then |
181 |
for F in $(ls /etc/fail2ban/fail2ban.d/);do |
182 |
rpm -qf /etc/fail2ban/fail2ban.d/$F >/dev/null 2>&1 || echo /etc/fail2ban/fail2ban.d/$F >> dir.list |
183 |
done |
184 |
fi |
185 |
if [ -d /etc/fail2ban/filter.d ]; then |
186 |
for F in $(ls /etc/fail2ban/filter.d/);do |
187 |
rpm -qf /etc/fail2ban/filter.d/$F >/dev/null 2>&1 || echo /etc/fail2ban/filter.d/$F >> dir.list |
188 |
done |
189 |
fi |
190 |
if [ -d /etc/fail2ban/jail.d ]; then |
191 |
for F in $(/etc/fail2ban/jail.d/);do |
192 |
rpm -qf /etc/fail2ban/jail.d/$F >/dev/null 2>&1 || echo /etc/fail2ban/jail.d/$F >> dir.list |
193 |
done |
194 |
fi |
195 |
rpm -q smeserver-grr >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
196 |
/usr/share/grr/images/ |
197 |
EOF |
198 |
rpm -q ipasserelle-im >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
199 |
/var/lib/ejabberd/ |
200 |
/var/log/ejabberd.run |
201 |
EOF |
202 |
#smeserver-isoqlog |
203 |
rpm -q smeserver-isoqlog >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
204 |
/var/lib/qmailtools/isoqlog/htdocs/ |
205 |
EOF |
206 |
rpm -q smeserver-jappix >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
207 |
/var/lib/jappix/ |
208 |
/var/log/jappix |
209 |
EOF |
210 |
rpm -q smeserver-lemonldap-ng >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
211 |
/var/lib/lemonldap-ng/conf |
212 |
/var/lib/lemonldap-ng/notifications |
213 |
EOF |
214 |
#smeserver-letsencrypt |
215 |
#rpm -q smeserver-letsencrypt >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
216 |
[ -d /etc/letsencrypt.sh/ ] && cat <<'EOF' >> dir.list |
217 |
/etc/letsencrypt.sh/ |
218 |
EOF |
219 |
[ -d /etc/dehydrated/ ] && cat <<'EOF' >> dir.list |
220 |
/etc/dehydrated/ |
221 |
EOF |
222 |
|
223 |
rpm -q smeserver-limesurvey >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
224 |
/var/lib/limesurvey/uploads |
225 |
EOF |
226 |
rpm -q ipasserelle-listes >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
227 |
/var/lib/mailman/ |
228 |
/usr/lib/mailman/aliases/ |
229 |
EOF |
230 |
if [ -d /usr/share/mozilla-mcd/ ]; then |
231 |
for F in /usr/share/mozilla-mcd/*;do |
232 |
rpm -qf $F >/dev/null 2>&1 || echo $F >> dir.list |
233 |
done |
234 |
fi |
235 |
rpm -q smeserver-madsonic >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
236 |
/var/madsonic/db/ |
237 |
/var/madsonic/madsonic.properties |
238 |
/var/madsonic/madsonic.log |
239 |
/var/madsonic/madsonic_sh.log |
240 |
EOF |
241 |
rpm -q smeserver-mailman >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
242 |
/var/lib/mailman/ |
243 |
/usr/lib/mailman/aliases/ |
244 |
EOF |
245 |
rpm -q smeserver-nextcloud >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
246 |
/usr/share/nextcloud/ |
247 |
EOF |
248 |
rpm -q smeserver-ntop >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
249 |
/var/lib/ntop/ |
250 |
EOF |
251 |
rpm -q phpki >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
252 |
/opt/phpki/phpki-store/ |
253 |
/opt/phpki/html/config.php |
254 |
EOF |
255 |
rpm -q smeserver-openvpn-bridge >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
256 |
/etc/openvpn/bridge/priv |
257 |
/etc/openvpn/bridge/pub |
258 |
/var/log/openvpn-bridge |
259 |
EOF |
260 |
rpm -q smeserver-openvpn-s2s >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
261 |
/etc/openvpn/s2s/priv |
262 |
/etc/openvpn/s2s/pub |
263 |
/var/log/openvpn-s2s |
264 |
EOF |
265 |
rpm -q smeserver-openvpn-routed >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
266 |
/etc/openvpn/routed/priv |
267 |
/etc/openvpn/routed/pub |
268 |
/var/log/openvpn-routed |
269 |
EOF |
270 |
rpm -q smeserver-phpki >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
271 |
/opt/phpki/ |
272 |
EOF |
273 |
rpm -q smeserver-phpki-ng >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
274 |
/opt/phpki/ |
275 |
EOF |
276 |
rpm -q pydio >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
277 |
/var/lib/pydio/files |
278 |
/var/lib/pydio/personal |
279 |
/var/lib/pydio/public |
280 |
/var/log/pydio |
281 |
EOF |
282 |
|
283 |
rpm -q smeserver-sarg >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
284 |
/var/www/sarg/ |
285 |
EOF |
286 |
#smeserver-sme8admin |
287 |
rpm -q smeserver-sme8admin >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
288 |
/var/lib/sme8admin/ |
289 |
EOF |
290 |
#smeserver-sme9admin |
291 |
rpm -q smeserver-sme9admin >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
292 |
/var/lib/sme9admin/ |
293 |
EOF |
294 |
#smeserver-sysmon |
295 |
rpm -q smeserver-sysmon >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
296 |
/var/lib/rrd/ |
297 |
EOF |
298 |
rpm -q smeserver-tftp-server >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
299 |
/tftpboot |
300 |
EOF |
301 |
rpm -q smeserver-transmission >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
302 |
/var/lib/transmission/Downloads |
303 |
EOF |
304 |
rpm -q smeserver-unifi >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
305 |
/opt/UniFi |
306 |
/opt/UniFi_bak |
307 |
EOF |
308 |
rpm -q smeserver-xinetd >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
309 |
/etc/rsyncd.conf |
310 |
/etc/xinetd.d/rsync |
311 |
/etc/logrotate.d/rsyncd |
312 |
EOF |
313 |
rpm -q smeserver-xt_geoip >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
314 |
/usr/share/xt_geoip/BE/ |
315 |
/usr/share/xt_geoip/LE/ |
316 |
/var/lib/xt_geoip/ |
317 |
EOF |
318 |
rpm -q smeserver-webfilter >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
319 |
/var/squidGuard/blacklists/ |
320 |
EOF |
321 |
#smeserver-webshares |
322 |
rpm -q smeserver-webshares >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
323 |
/opt/webshare |
324 |
EOF |
325 |
# smeserver-zabbix-server smeserver-zabbix-agent smeserver-zabbix-proxy |
326 |
if [ -d /etc/zabbix ]; then |
327 |
for F in /etc/zabbix/*;do |
328 |
rpm -qf $F >/dev/null 2>&1 || echo $F >> dir.list |
329 |
done |
330 |
fi |
331 |
if [ -d /etc/zabbix/zabbix_agentd.conf.d ]; then |
332 |
for F in /etc/zabbix/zabbix_agentd.conf.d/*;do |
333 |
rpm -qf $F >/dev/null 2>&1 || echo $F >> dir.list |
334 |
done |
335 |
fi |
336 |
if [ -d /var/lib/zabbix/bin ]; then |
337 |
for F in /var/lib/zabbix/bin/*;do |
338 |
rpm -qf $F >/dev/null 2>&1 || echo $F >> dir.list |
339 |
done |
340 |
fi |
341 |
rpm -q smeserver-zoneminder >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
342 |
/var/lib/zoneminder |
343 |
/var/log/zoneminder |
344 |
/var/spool/zoneminder-upload |
345 |
EOF |
346 |
|
347 |
#contribs we are aware of, but NOTHING TO DO |
348 |
#smeserver-email-management |
349 |
#smeserver-geoip |
350 |
#smeserver-kronolith |
351 |
#smeserver-lazy_admin_tools |
352 |
#smeserver-learn |
353 |
#smeserver-mailsorting |
354 |
#smeserver-mailstats |
355 |
#smeserver-mod_dav |
356 |
#smeserver-nag |
357 |
#smeserver-php-fpm |
358 |
#smeserver-php-scl |
359 |
#smeserver-phpldapadmin. |
360 |
#smeserver-phpsysinfo |
361 |
#smeserver-qmHandle |
362 |
#smeserver-remoteuseraccess |
363 |
#smeserver-userpanel |
364 |
#smeserver-userpanels |
365 |
#smeserver-vacation |
366 |
#smeserver-wbl |
367 |
#smeserver-webapps-common |
368 |
#smeserver-webhosting |
369 |
#smeserver-bridge-interface |
370 |
#smeserver-ddclient |
371 |
#smeserver-mediatomb |
372 |
#smeserver-sane |
373 |
#smeserver-usbdisksmanager |
374 |
|
375 |
#we might get issue there with .rpmnew files |
376 |
# but we need to get the same version as in db |
377 |
|
378 |
# for F in /usr/share/nextcloud/apps/*;do |
379 |
# rpm -qf $F >/dev/null 2>&1 || echo $F >> dir.list |
380 |
# done |
381 |
|
382 |
|
383 |
|
384 |
## add here selection for test or live and stop services |
385 |
/sbin/e-smith/audittools/newrpms > /root/newrpms |
386 |
cat /root/newrpms|grep @ |cut -d' ' -f1|sed 's/.noarch//g'| sed 's/.x86_64//g'|sed 's/.i386//g'|sort|grep smeserver >/root/contribs |
387 |
cat /root/newrpms|grep @ |cut -d' ' -f1|sed 's/.noarch//g'| sed 's/.x86_64//g'|sed 's/.i386//g'|sort >/root/rpmsextra |
388 |
#ADD here |
389 |
mkdir -p /root/migratehelper/{yumDownload,lists} |
390 |
# filter out in file per repo |
391 |
# run trhough all created files for /root/migratehelper/lists/RpmsPerRepos_*.list |
392 |
# and yum reinstall --downloadonly --downloaddir=/root/migratehelper/yumDownload # mayded followed by yum update --downloadonly --downloaddir=/root/migratehelper/yumDownload |
393 |
# or yum install --downloadonly --downloaddir=/root/migratehelper/yumDownload --installroot=/root/migratehelper/ smeserver-yum --enablerepo=smeos,base --releasever=6 |
394 |
# or after requiring yum-utils (bug it seems to only download to current dir whatever you do: |
395 |
# cd /root/migratehelper/yumDownload; yumdownloader install --downloadonly --downloaddir=. smeserver-freepbx -y --diablerepo=* --enablerepo=$repo --releasever=6 |
396 |
|
397 |
#### stop services so no changes occurs |
398 |
if [ -e /usr/lib/systemd/system/qmail.service ]; then |
399 |
/usr/bin/systemctl stop qmail.service qpsmtpd.service sqpsmtpd.service ejabberd.service smb.service smbd.service nmbd.service httpd-e-smith.service |
400 |
else |
401 |
sv d /service/qmail |
402 |
sv d /service/qpsmtpd |
403 |
sv d /service/sqpsmtpd |
404 |
[ -e /service/ejabberd ] && sv d /service/ejabberd |
405 |
sv d /service/smbd |
406 |
sv d /service/httpd-e-smith |
407 |
fi |
408 |
#### prebackup |
409 |
signal-event pre-backup |
410 |
tar cvzf /mnt/backup/smeserver.tgz -T dir.list --exclude-from exclude.list --xattrs |