/[smecontribs]/rpms/smeserver-migratehelper/contribs10/migratehelper.sh
ViewVC logotype

Annotation of /rpms/smeserver-migratehelper/contribs10/migratehelper.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (hide annotations) (download) (as text)
Fri Apr 2 02:33:53 2021 UTC (3 years, 7 months ago) by jpp
Branch: MAIN
CVS Tags: smeserver-migratehelper-1_0-2_el7_sme
Changes since 1.1: +4 -0 lines
Content type: application/x-sh
* Thu Apr 01 2021 Jean-Philippe Pialasse <tests@pialasse.com> 1.0-2.sme
- add backup of spamassassin admin config
- add search for non rpm owned folder in /usr/local

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

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed