/[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.1 - (hide annotations) (download) (as text)
Wed Mar 31 04:12:02 2021 UTC (3 years, 7 months ago) by jpp
Branch: MAIN
CVS Tags: smeserver-migratehelper-1_0-1_el7_sme
Content type: application/x-sh
* Sat Jan 05 2019 Jean-Philipe Pialasse <tests@pialasse.com> 1.0-1.sme
- initial release [SME: 11275]
- TODO use SME 10 includes / excludes

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