/[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.5 - (hide annotations) (download) (as text)
Fri Oct 22 02:13:38 2021 UTC (3 years, 1 month ago) by jpp
Branch: MAIN
CVS Tags: smeserver-migratehelper-1_0-5_el7_sme
Changes since 1.4: +17 -0 lines
Content type: application/x-sh
* Thu Oct 21 2021 Jean-Philippe Pialasse <tests@pialasse.com> 1.0-5.sme
- fix missing samba domain user [SME: 11706]
- fix missing user cron jobs [SME: 11664]

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