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

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

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

Revision 1.2 by jpp, Fri Apr 2 02:33:53 2021 UTC Revision 1.6 by jcrisp, Sat Nov 13 14:52:01 2021 UTC
# Line 1  Line 1 
1  #!/bin/bash  #!/bin/bash
2    
3  cd /root  echo "#*************************************************************************# "
4  # list of included files to the backup  echo "# Note we are NOT including >>"
5  # note we are not including /home/e-smith/{files,shares} and /home/e-smith/db/mysql*/{daily,hourly}  echo "# /home/e-smith/{files,shares} "
6  # you are responsible to backup and restore them separatly  echo "# /home/e-smith/db/mysql*/{daily,hourly}"
7  cat <<'EOF' > dir.list  echo "# "
8    echo "# You are responsible for backing up and restoring them separately"
9    echo "#*************************************************************************# "
10    
11    TEST="n"  # Set Test mode default
12    VERSION=1 # Just because
13    NOCHECK="0"
14    
15    # ===========================================================================
16    
17    function usage() { # Function: Print a help message.
18      echo "Usage: $0 [ -t Enable Test mode ] [ -n no-check ] [ -v Version ] [ -h Help ]" 1>&2
19    }
20    
21    function exit_abnormal() { # Function: Exit with error.
22      usage
23      exit 1
24    }
25    
26    function prompt_confirm() {
27      while true; do
28        read -r -n 1 -p "${1:-Continue?} [y/n]: " REPLY
29        case $REPLY in
30        [yY])
31          echo
32          return 0
33          ;;
34        [nN])
35          echo
36          return 1
37          ;;
38        *) printf " \033[31m %s \n\033[0m" "invalid input" ;;
39        esac
40      done
41    }
42    
43    while getopts ":vthn" options; do # Loop: Get the next option;
44      # use silent error checking;
45      # options have no arguments
46      case "${options}" in #
47      v)                   # If the option is n,
48        echo "Version $VERSION"
49        exit_abnormal
50        ;;
51      t)         # If the option is t,
52        TEST="y" # Set $TEST
53        ;;
54      n)
55        echo "Checking"
56        NOCHECK="1"
57        ;;
58      h)
59        exit_abnormal
60        ;;
61    
62      \?) # If unknown (any other) option:
63        echo "invalid_option"
64        exit_abnormal # Exit abnormally.
65        ;;
66    
67      *) # If unknown (any other) option:
68        echo "unknown_option"
69        exit_abnormal # Exit abnormally.
70        ;;
71    
72        # Me hacking about
73        #    :)                                    # If expected argument omitted:
74        #      echo "Error: -${OPTARG} requires an argument."
75        #      exit_abnormal                       # Exit abnormally.
76        #      ;;
77    
78      esac
79    
80    done
81    
82    if [ "$NOCHECK" = "0" ]; then
83      prompt_confirm "Can we start?" || exit 0
84    fi
85    
86    # Let's go.
87    echo "Starting - please be patient"
88    
89    if [ "$TEST" = "y" ]; then
90      echo "We are in TEST mode. No backup will be created or services affected"
91    else
92      echo "We are in REAL mode."
93      echo "This creates a backup file for restore"
94      echo "The file includes and excludes various items"
95      echo "All files, mails and MySQL DBS are not included"
96      echo "We will create the backup file like this"
97      echo "tar cvzf /mnt/backup/smeserver.tgz -T dir.list --exclude-from exclude.list"
98      echo ""
99      echo "After the script has finished all mail/file.web services will be stopped"
100      echo "Copy the backup to your new server, and manually copy over the remaining files"
101    fi
102    
103    # Added failure check
104    # https://github.com/koalaman/shellcheck/wiki/SC2164
105    
106    cd /root || exit_abnormal
107    
108    cat <<'EOF' >dir.list
109  /etc/e-smith/templates-custom  /etc/e-smith/templates-custom
110  /etc/e-smith/templates-user-custom  /etc/e-smith/templates-user-custom
111  /etc/group  /etc/group
# Line 13  cat <<'EOF' > dir.list Line 114  cat <<'EOF' > dir.list
114  /etc/samba/secrets.tdb  /etc/samba/secrets.tdb
115  /etc/samba/smbpasswd  /etc/samba/smbpasswd
116  /etc/shadow  /etc/shadow
 /etc/smbpasswd  
117  /etc/ssh  /etc/ssh
118  /etc/sudoers  /etc/sudoers
119  /root  /root
# Line 33  cat <<'EOF' > dir.list Line 133  cat <<'EOF' > dir.list
133  /var/log/iptables/  /var/log/iptables/
134  /var/spool/mail/  /var/spool/mail/
135  /var/spool/spamd/  /var/spool/spamd/
136    /var/spool/cron/
137  EOF  EOF
138    
139  [ -e /var/log/samba/samba_audit ] && cat <<'EOF' >> dir.list  [ -e /etc/smbpasswd ] && cat <<'EOF' >>dir.list
140    /etc/smbpasswd
141    EOF
142    
143    [ -e /var/log/samba/samba_audit ] && cat <<'EOF' >>dir.list
144  /var/log/samba/samba_audit  /var/log/samba/samba_audit
145  EOF  EOF
146    
147  [ -e /var/service/qpsmtpd/config/dkimkeys/ ] && cat <<'EOF' >> dir.list  [ -e /etc/samba/schannel_store.tdb ] && cat <<'EOF' >>dir.list
148    /etc/samba/schannel_store.tdb
149    EOF
150    
151    [ -e /var/lib/samba/group_mapping.tdb ] && cat <<'EOF' >>dir.list
152    /var/lib/samba/group_mapping.tdb
153    EOF
154    
155    [ -e /var/lib/samba/account_policy.tdb ] && cat <<'EOF' >>dir.list
156    /var/lib/samba/account_policy.tdb
157    EOF
158    
159    [ -e /var/log/samba/samba_audit ] && cat <<'EOF' >>dir.list
160    /var/log/samba/samba_audit
161    EOF
162    
163    [ -e /var/service/qpsmtpd/config/dkimkeys/ ] && cat <<'EOF' >>dir.list
164  /var/service/qpsmtpd/config/dkimkeys/  /var/service/qpsmtpd/config/dkimkeys/
165  EOF  EOF
166    
# Line 65  cat <<EOF >exclude.list Line 186  cat <<EOF >exclude.list
186  EOF  EOF
187    
188  ## add here exclusion from db key  ## add here exclusion from db key
189    # Added -print0 here - also needs -0 on xargs
190  # search for local script added  # https://github.com/koalaman/shellcheck/wiki/SC2038
191  find /usr/local/bin/ -type f | xargs -I % sh -c "rpm -qf % 2>&1 > /dev/null || echo % >> dir.list"  # search for local script added
192    find /usr/local/bin/ -type f -print0 | xargs -0 -I % sh -c "rpm -qf % 2>&1 > /dev/null || echo % >> dir.list"
193  # search for local dir script added  # search for local dir script added
194  find /usr/local/ -maxdepth 1  -type d | xargs -I % sh -c "rpm -qf % 2>&1 > /dev/null || echo % >> dir.list"  find /usr/local/ -maxdepth 1 -type d -print0 | xargs -0 -I % sh -c "rpm -qf % 2>&1 > /dev/null || echo % >> dir.list"
195  # search for cron files not owned by a rpm  # search for cron files not owned by a rpm
196  find /etc/cron.* -type f | xargs -I % sh -c "rpm -qf % 2>&1 > /dev/null || echo % >> dir.list"  find /etc/cron.* -type f -print0 | xargs -0 -I % sh -c "rpm -qf % 2>&1 > /dev/null || echo % >> dir.list"
197  # search for udev rules not owned by a rpm ! oucl add an option there in case you change of hardware  # search for udev rules not owned by a rpm ! oucl add an option there in case you change of hardware
198  find /etc/udev/rules.d/ -type f | xargs -I % sh -c "rpm -qf % 2>&1 > /dev/null || echo % >> dir.list"  find /etc/udev/rules.d/ -type f -print0 | xargs -0 -I % sh -c "rpm -qf % 2>&1 > /dev/null || echo % >> dir.list"
199  # search for spamassassin user created config  # search for spamassassin user created config
200  find /etc/mail/spamassassin -maxdepth 1 -type f | xargs -I % sh -c "rpm -qf % 2>&1 > /dev/null || echo % >> dir.list"  find /etc/mail/spamassassin -maxdepth 1 -type f -print0 | xargs -0 -I % sh -c "rpm -qf % 2>&1 > /dev/null || echo % >> dir.list"
201    
202  ##################  ##################
203  #  #
204  # here starts the magic  # here starts the magic
205  # we backup each known corpm -q smeserver-dovecot ntribs folder  # we backup each known contribs folder
206  #  #
207  ##################  ##################
208  #smeserver-awstats.noarch    #smeserver-awstats.noarch
209  # data will be in /home/e-smith/files/users/admin  # data will be in /home/e-smith/files/users/admin
210  # we only backup the config files  # we only backup the config files
211  rpm -q smeserver-awstats  >/dev/null  2>&1 && cat <<'EOF' >> dir.list  rpm -q smeserver-awstats >/dev/null 2>&1 && cat <<'EOF' >>dir.list
212  /etc/e-smith/web/panels/manager/cgi-bin/.awstats/  /etc/e-smith/web/panels/manager/cgi-bin/.awstats/
213  EOF  EOF
214  # see with Daniel if they have a specific config  # see with Daniel if they have a specific config
215  #rpm -q awstats >/dev/null 2>&1 && cat <<'EOF' >> dir.list  #rpm -q awstats >/dev/null 2>&1 && cat <<'EOF' >> dir.list
216  #/var/lib/awstats  #/var/lib/awstats
217  #EOF  #EOF
218  #for those we assume you handle yourself the backup or the pools in /var/lib/BackupPC  #for those we assume you handle yourself the backup or the pools in /var/lib/BackupPC
219  rpm -q smeserver-BackupPC >/dev/null 2>&1 && cat <<'EOF' >> dir.list  rpm -q smeserver-BackupPC >/dev/null 2>&1 && cat <<'EOF' >>dir.list
220  /etc/BackupPC  /etc/BackupPC
221  EOF  EOF
222  rpm -q smeserver-BackupPC4 >/dev/null 2>&1 && cat <<'EOF' >> dir.list  rpm -q smeserver-BackupPC4 >/dev/null 2>&1 && cat <<'EOF' >>dir.list
223  /etc/BackupPC  /etc/BackupPC
224  EOF  EOF
225  rpm -q smeserver-bandwidthd >/dev/null 2>&1 && cat <<'EOF' >> dir.list  rpm -q smeserver-bandwidthd >/dev/null 2>&1 && cat <<'EOF' >>dir.list
226  /var/www/bandwidthd/  /var/www/bandwidthd/
227  EOF  EOF
228  #smeserver-clamav-unofficial-sigs and clamav-unofficial-sigs  #smeserver-clamav-unofficial-sigs and clamav-unofficial-sigs
229  rpm -q smeserver-clamav-unofficial-sigs  >/dev/null  2>&1 && cat <<'EOF' >> dir.list  rpm -q smeserver-clamav-unofficial-sigs >/dev/null 2>&1 && cat <<'EOF' >>dir.list
230  /var/lib/clamav-unofficial-sigs/  /var/lib/clamav-unofficial-sigs/
231  EOF  EOF
232  #smeserver-dansguardian smeserver-dansguardian-panel  #smeserver-dansguardian smeserver-dansguardian-panel
233  rpm -q smeserver-dansguardian >/dev/null 2>&1 && cat <<'EOF' >> dir.list  rpm -q smeserver-dansguardian >/dev/null 2>&1 && cat <<'EOF' >>dir.list
234  /etc/dansguardian/  /etc/dansguardian/
235  EOF  EOF
236  #smeserver-denyhosts  #smeserver-denyhosts
237  rpm -q smeserver-denyhosts  >/dev/null 2>&1 && cat <<'EOF' >> dir.list  rpm -q smeserver-denyhosts >/dev/null 2>&1 && cat <<'EOF' >>dir.list
238  /var/lib/denyhosts/  /var/lib/denyhosts/
239  /etc/hosts.deny_ssh  /etc/hosts.deny_ssh
240  /etc/hosts.deny_ssh.purge.bak  /etc/hosts.deny_ssh.purge.bak
241  EOF  EOF
242  rpm -q smeserver-dl >/dev/null 2>&1 && cat <<'EOF' >> dir.list  rpm -q smeserver-dl >/dev/null 2>&1 && cat <<'EOF' >>dir.list
243  /var/lib/dl/  /var/lib/dl/
244  EOF  EOF
245  rpm -q dokuwiki >/dev/null 2>&1 && cat <<'EOF' >> dir.list  rpm -q dokuwiki >/dev/null 2>&1 && cat <<'EOF' >>dir.list
246  /etc/dokuwiki/acl.auth.php  /etc/dokuwiki/acl.auth.php
247  /etc/dokuwiki/acronyms.conf  /etc/dokuwiki/acronyms.conf
248  /etc/dokuwiki/entities.conf  /etc/dokuwiki/entities.conf
# Line 136  rpm -q dokuwiki >/dev/null 2>&1 && cat < Line 258  rpm -q dokuwiki >/dev/null 2>&1 && cat <
258  /var/lib/dokuwiki/data/meta  /var/lib/dokuwiki/data/meta
259  /var/lib/dokuwiki/data/pages  /var/lib/dokuwiki/data/pages
260  EOF  EOF
261  rpm -q dokuwiki >/dev/null 2>&1 && for D in /usr/share/dokuwiki/lib/plugins/*;do  rpm -q dokuwiki >/dev/null 2>&1 && for D in /usr/share/dokuwiki/lib/plugins/*; do
262    rpm -qf $D >/dev/null 2>&1 || echo $D >> dir.list    rpm -qf "$D" >/dev/null 2>&1 || echo "$D" >>dir.list
263  done  done
264    
265    #rpm -q smeserver-dovecot >/dev/null  2>&1 && cat <<'EOF' >> dir.list
266  rpm -q smeserver-dovecot >/dev/null  2>&1 && cat <<'EOF' >> dir.list  [ -e /etc/dovecot/sharemailbox ] && cat <<'EOF' >>dir.list
267  /etc/dovecot/sharemailbox/  /etc/dovecot/sharemailbox/
268  EOF  EOF
269    
270  #smeserver-durep  #smeserver-durep
271  rpm -q smeserver-durep  >/dev/null  2>&1 && cat <<'EOF' >> dir.list  rpm -q smeserver-durep >/dev/null 2>&1 && cat <<'EOF' >>dir.list
272  /var/lib/durep  /var/lib/durep
273  EOF  EOF
274  #smeserver-ezmlm-web  #smeserver-ezmlm-web
275  rpm -q smeserver-ezmlm-web  >/dev/null  2>&1 && cat <<'EOF' >> dir.list  rpm -q smeserver-ezmlm-web >/dev/null 2>&1 && cat <<'EOF' >>dir.list
276  /home/e-smith/files/ezmlm  /home/e-smith/files/ezmlm
277  EOF  EOF
278  [ -e /var/lib/phone ] && cat <<'EOF' >> dir.list  [ -e /var/lib/phone ] && cat <<'EOF' >>dir.list
279  /var/lib/phone  /var/lib/phone
280  EOF  EOF
281  rpm -q smeserver-freepbx >/dev/null 2>&1 && cat <<'EOF' >> dir.list  rpm -q smeserver-freepbx >/dev/null 2>&1 && cat <<'EOF' >>dir.list
282  /opt/freepbx  /opt/freepbx
283  /var/lib/asterisk/  /var/lib/asterisk/
284  /etc/asterisk  /etc/asterisk
# Line 167  rpm -q smeserver-freepbx >/dev/null 2>&1 Line 289  rpm -q smeserver-freepbx >/dev/null 2>&1
289  /usr/sbin/amportal  /usr/sbin/amportal
290  /usr/sbin/fwconsole  /usr/sbin/fwconsole
291  EOF  EOF
292  # smeserver-fail2ban  # smeserver-fail2ban
293  if [ -d /etc/fail2ban/action.d ]; then  if [ -d /etc/fail2ban/action.d ]; then
294    for F in /etc/fail2ban/action.d/*;do    for F in /etc/fail2ban/action.d/*; do
295      rpm -qf $F >/dev/null 2>&1 || echo $F >> dir.list      rpm -qf /etc/fail2ban/action.d/"$F" >/dev/null 2>&1 || echo /etc/fail2ban/action.d/"$F" >>dir.list
296    done    done
297  fi  fi
298  if [ -d /etc/fail2ban/fail2ban.d ]; then  if [ -d /etc/fail2ban/fail2ban.d ]; then
299    for F in /etc/fail2ban/fail2ban.d/*;do    for F in /etc/fail2ban/fail2ban.d*; do
300      rpm -qf $F >/dev/null 2>&1 || echo $F >> dir.list      rpm -qf /etc/fail2ban/fail2ban.d/"$F" >/dev/null 2>&1 || echo /etc/fail2ban/fail2ban.d/"$F" >>dir.list
301    done    done
302  fi  fi
303  if [ -d /etc/fail2ban/filter.d ]; then  if [ -d /etc/fail2ban/filter.d ]; then
304    for F in /etc/fail2ban/filter.d/*;do    for F in /etc/fail2ban/filter.d/*; do
305      rpm -qf $F >/dev/null 2>&1 || echo $F >> dir.list      rpm -qf /etc/fail2ban/filter.d/"$F" >/dev/null 2>&1 || echo /etc/fail2ban/filter.d/"$F" >>dir.list
306    done    done
307  fi  fi
308  if [ -d /etc/fail2ban/jail.d ]; then  if [ -d /etc/fail2ban/jail.d ]; then
309    for F in /etc/fail2ban/jail.d/*;do    for F in /etc/fail2ban/jail.d/*; do
310      rpm -qf $F >/dev/null 2>&1 || echo $F >> dir.list      rpm -qf /etc/fail2ban/jail.d/"$F" >/dev/null 2>&1 || echo /etc/fail2ban/jail.d/"$F" >>dir.list
311    done    done
312  fi  fi
313  rpm -q smeserver-grr >/dev/null 2>&1 && cat <<'EOF' >> dir.list  rpm -q smeserver-grr >/dev/null 2>&1 && cat <<'EOF' >>dir.list
314  /usr/share/grr/images/  /usr/share/grr/images/
315  EOF  EOF
316  rpm -q ipasserelle-im >/dev/null 2>&1 && cat <<'EOF' >> dir.list  rpm -q ipasserelle-im >/dev/null 2>&1 && cat <<'EOF' >>dir.list
317  /var/lib/ejabberd/  /var/lib/ejabberd/
318  /var/log/ejabberd.run  /var/log/ejabberd.run
319  EOF  EOF
320  #smeserver-isoqlog  #smeserver-isoqlog
321  rpm -q smeserver-isoqlog  >/dev/null 2>&1 && cat <<'EOF' >> dir.list  rpm -q smeserver-isoqlog >/dev/null 2>&1 && cat <<'EOF' >>dir.list
322  /var/lib/qmailtools/isoqlog/htdocs/  /var/lib/qmailtools/isoqlog/htdocs/
323  EOF  EOF
324  rpm -q smeserver-jappix >/dev/null 2>&1 && cat <<'EOF' >> dir.list  rpm -q smeserver-jappix >/dev/null 2>&1 && cat <<'EOF' >>dir.list
325  /var/lib/jappix/  /var/lib/jappix/
326  /var/log/jappix  /var/log/jappix
327  EOF  EOF
328  rpm -q smeserver-lemonldap-ng >/dev/null 2>&1 && cat <<'EOF' >> dir.list  rpm -q smeserver-lemonldap-ng >/dev/null 2>&1 && cat <<'EOF' >>dir.list
329  /var/lib/lemonldap-ng/conf  /var/lib/lemonldap-ng/conf
330  /var/lib/lemonldap-ng/notifications  /var/lib/lemonldap-ng/notifications
331  EOF  EOF
332  #smeserver-letsencrypt  #smeserver-letsencrypt
333  rpm -q smeserver-letsencrypt  >/dev/null  2>&1 && cat <<'EOF' >> dir.list  #rpm -q smeserver-letsencrypt  >/dev/null  2>&1 && cat <<'EOF' >> dir.list
334    [ -d /etc/letsencrypt.sh/ ] && cat <<'EOF' >>dir.list
335  /etc/letsencrypt.sh/  /etc/letsencrypt.sh/
336    EOF
337    [ -d /etc/dehydrated/ ] && cat <<'EOF' >>dir.list
338  /etc/dehydrated/  /etc/dehydrated/
339  EOF  EOF
340  rpm -q smeserver-limesurvey >/dev/null 2>&1 && cat <<'EOF' >> dir.list  
341    rpm -q smeserver-limesurvey >/dev/null 2>&1 && cat <<'EOF' >>dir.list
342  /var/lib/limesurvey/uploads  /var/lib/limesurvey/uploads
343  EOF  EOF
344  rpm -q ipasserelle-listes >/dev/null 2>&1 && cat <<'EOF' >> dir.list  rpm -q ipasserelle-listes >/dev/null 2>&1 && cat <<'EOF' >>dir.list
345  /var/lib/mailman/  /var/lib/mailman/
346  /usr/lib/mailman/aliases/  /usr/lib/mailman/aliases/
347  EOF  EOF
348  if [ -d /usr/share/mozilla-mcd/ ]; then  if [ -d /usr/share/mozilla-mcd/ ]; then
349    for F in /usr/share/mozilla-mcd/*;do    for F in /usr/share/mozilla-mcd/*; do
350      rpm -qf $F >/dev/null 2>&1 || echo $F >> dir.list      rpm -qf "$F" >/dev/null 2>&1 || echo "$F" >>dir.list
351    done    done
352  fi  fi
353  rpm -q smeserver-madsonic >/dev/null 2>&1 && cat <<'EOF' >> dir.list  rpm -q smeserver-madsonic >/dev/null 2>&1 && cat <<'EOF' >>dir.list
354  /var/madsonic/db/  /var/madsonic/db/
355  /var/madsonic/madsonic.properties  /var/madsonic/madsonic.properties
356  /var/madsonic/madsonic.log  /var/madsonic/madsonic.log
357  /var/madsonic/madsonic_sh.log  /var/madsonic/madsonic_sh.log
358  EOF  EOF
359  rpm -q smeserver-mailman >/dev/null 2>&1 && cat <<'EOF' >> dir.list  rpm -q smeserver-mailman >/dev/null 2>&1 && cat <<'EOF' >>dir.list
360  /var/lib/mailman/  /var/lib/mailman/
361  /usr/lib/mailman/aliases/  /usr/lib/mailman/aliases/
362  EOF  EOF
363  rpm -q smeserver-nextcloud >/dev/null 2>&1 && cat <<'EOF' >> dir.list  rpm -q smeserver-nextcloud >/dev/null 2>&1 && cat <<'EOF' >>dir.list
364  /usr/share/nextcloud/  /usr/share/nextcloud/
365  EOF  EOF
366  rpm -q smeserver-ntop >/dev/null 2>&1 && cat <<'EOF' >> dir.list  rpm -q smeserver-ntop >/dev/null 2>&1 && cat <<'EOF' >>dir.list
367  /var/lib/ntop/  /var/lib/ntop/
368  EOF  EOF
369  rpm -q phpki >/dev/null 2>&1 && cat <<'EOF' >> dir.list  rpm -q phpki >/dev/null 2>&1 && cat <<'EOF' >>dir.list
370  /opt/phpki/phpki-store/  /opt/phpki/phpki-store/
371  /opt/phpki/html/config.php  /opt/phpki/html/config.php
372  EOF  EOF
373  rpm -q smeserver-openvpn-bridge >/dev/null 2>&1 && cat <<'EOF' >> dir.list  rpm -q smeserver-openvpn-bridge >/dev/null 2>&1 && cat <<'EOF' >>dir.list
374  /etc/openvpn/bridge/priv  /etc/openvpn/bridge/priv
375  /etc/openvpn/bridge/pub  /etc/openvpn/bridge/pub
376  /var/log/openvpn-bridge  /var/log/openvpn-bridge
377  EOF  EOF
378  rpm -q smeserver-openvpn-s2s >/dev/null 2>&1 && cat <<'EOF' >> dir.list  rpm -q smeserver-openvpn-s2s >/dev/null 2>&1 && cat <<'EOF' >>dir.list
379  /etc/openvpn/s2s/priv  /etc/openvpn/s2s/priv
380  /etc/openvpn/s2s/pub  /etc/openvpn/s2s/pub
381  /var/log/openvpn-s2s  /var/log/openvpn-s2s
382  EOF  EOF
383  rpm -q smeserver-openvpn-routed >/dev/null 2>&1 && cat <<'EOF' >> dir.list  rpm -q smeserver-openvpn-routed >/dev/null 2>&1 && cat <<'EOF' >>dir.list
384  /etc/openvpn/routed/priv  /etc/openvpn/routed/priv
385  /etc/openvpn/routed/pub  /etc/openvpn/routed/pub
386  /var/log/openvpn-routed  /var/log/openvpn-routed
387  EOF  EOF
388  rpm -q smeserver-phpki  >/dev/null 2>&1 && cat <<'EOF' >> dir.list  rpm -q smeserver-phpki >/dev/null 2>&1 && cat <<'EOF' >>dir.list
389  /opt/phpki/  /opt/phpki/
390  EOF  EOF
391  rpm -q smeserver-phpki-ng  >/dev/null 2>&1 && cat <<'EOF' >> dir.list  rpm -q smeserver-phpki-ng >/dev/null 2>&1 && cat <<'EOF' >>dir.list
392  /opt/phpki/  /opt/phpki/
393  EOF  EOF
394  rpm -q pydio >/dev/null 2>&1 && cat <<'EOF' >> dir.list  rpm -q pydio >/dev/null 2>&1 && cat <<'EOF' >>dir.list
395  /var/lib/pydio/files  /var/lib/pydio/files
396  /var/lib/pydio/personal  /var/lib/pydio/personal
397  /var/lib/pydio/public  /var/lib/pydio/public
398  /var/log/pydio  /var/log/pydio
399  EOF  EOF
400    
401  rpm -q smeserver-sarg >/dev/null 2>&1 && cat <<'EOF' >> dir.list  rpm -q smeserver-sarg >/dev/null 2>&1 && cat <<'EOF' >>dir.list
402  /var/www/sarg/  /var/www/sarg/
403  EOF  EOF
404  #smeserver-sme8admin  #smeserver-sme8admin
405  rpm -q smeserver-sme8admin  >/dev/null  2>&1 && cat <<'EOF' >> dir.list  rpm -q smeserver-sme8admin >/dev/null 2>&1 && cat <<'EOF' >>dir.list
406  /var/lib/sme8admin/  /var/lib/sme8admin/
407  EOF  EOF
408  #smeserver-sme9admin  #smeserver-sme9admin
409  rpm -q smeserver-sme9admin  >/dev/null  2>&1 && cat <<'EOF' >> dir.list  rpm -q smeserver-sme9admin >/dev/null 2>&1 && cat <<'EOF' >>dir.list
410  /var/lib/sme9admin/  /var/lib/sme9admin/
411  EOF  EOF
412  #smeserver-sysmon  #smeserver-sysmon
413  rpm -q smeserver-sysmon  >/dev/null 2>&1 && cat <<'EOF' >> dir.list  rpm -q smeserver-sysmon >/dev/null 2>&1 && cat <<'EOF' >>dir.list
414  /var/lib/rrd/  /var/lib/rrd/
415  EOF  EOF
416  rpm -q smeserver-tftp-server >/dev/null 2>&1 && cat <<'EOF' >> dir.list  rpm -q smeserver-tftp-server >/dev/null 2>&1 && cat <<'EOF' >>dir.list
417  /tftpboot  /tftpboot
418  EOF  EOF
419  rpm -q smeserver-transmission >/dev/null 2>&1 && cat <<'EOF' >> dir.list  rpm -q smeserver-transmission >/dev/null 2>&1 && cat <<'EOF' >>dir.list
420  /var/lib/transmission/Downloads  /var/lib/transmission/Downloads
421  EOF  EOF
422  rpm -q smeserver-unifi >/dev/null 2>&1 && cat <<'EOF' >> dir.list  rpm -q smeserver-unifi >/dev/null 2>&1 && cat <<'EOF' >>dir.list
423  /opt/UniFi  /opt/UniFi
424  /opt/UniFi_bak  /opt/UniFi_bak
425  EOF  EOF
426  rpm -q  smeserver-xinetd >/dev/null 2>&1 && cat <<'EOF' >> dir.list  rpm -q smeserver-xinetd >/dev/null 2>&1 && cat <<'EOF' >>dir.list
427  /etc/rsyncd.conf  /etc/rsyncd.conf
428  /etc/xinetd.d/rsync  /etc/xinetd.d/rsync
429  /etc/logrotate.d/rsyncd  /etc/logrotate.d/rsyncd
430  EOF  EOF
431  rpm -q smeserver-xt_geoip >/dev/null 2>&1 && cat <<'EOF' >> dir.list  rpm -q smeserver-xt_geoip >/dev/null 2>&1 && cat <<'EOF' >>dir.list
432  /usr/share/xt_geoip/BE/  /usr/share/xt_geoip/BE/
433  /usr/share/xt_geoip/LE/  /usr/share/xt_geoip/LE/
434  /var/lib/xt_geoip/  /var/lib/xt_geoip/
435  EOF  EOF
436  rpm -q smeserver-webfilter >/dev/null 2>&1 && cat <<'EOF' >> dir.list  rpm -q smeserver-webfilter >/dev/null 2>&1 && cat <<'EOF' >>dir.list
437  /var/squidGuard/blacklists/  /var/squidGuard/blacklists/
438  EOF  EOF
439  #smeserver-webshares  #smeserver-webshares
440  rpm -q smeserver-webshares  >/dev/null  2>&1 && cat <<'EOF' >> dir.list  rpm -q smeserver-webshares >/dev/null 2>&1 && cat <<'EOF' >>dir.list
441  /opt/webshare  /opt/webshare
442  EOF  EOF
443  # smeserver-zabbix-server smeserver-zabbix-agent smeserver-zabbix-proxy  # smeserver-zabbix-server smeserver-zabbix-agent smeserver-zabbix-proxy
444  if [ -d /etc/zabbix ]; then  if [ -d /etc/zabbix ]; then
445    for F in /etc/zabbix/*;do    for F in /etc/zabbix/*; do
446      rpm -qf $F >/dev/null 2>&1 || echo $F >> dir.list      rpm -qf "$F" >/dev/null 2>&1 || echo "$F" >>dir.list
447    done    done
448  fi  fi
449  if [ -d /etc/zabbix/zabbix_agentd.conf.d ]; then  if [ -d /etc/zabbix/zabbix_agentd.conf.d ]; then
450    for F in /etc/zabbix/zabbix_agentd.conf.d/*;do    for F in /etc/zabbix/zabbix_agentd.conf.d/*; do
451      rpm -qf $F >/dev/null 2>&1 || echo $F >> dir.list      rpm -qf "$F" >/dev/null 2>&1 || echo "$F" >>dir.list
452    done    done
453  fi  fi
454  if [ -d /var/lib/zabbix/bin ]; then  if [ -d /var/lib/zabbix/bin ]; then
455    for F in /var/lib/zabbix/bin/*;do    for F in /var/lib/zabbix/bin/*; do
456      rpm -qf $F >/dev/null 2>&1 || echo $F >> dir.list      rpm -qf "$F" >/dev/null 2>&1 || echo "$F" >>dir.list
457    done    done
458  fi  fi
459  rpm -q smeserver-zoneminder  >/dev/null 2>&1 && cat <<'EOF' >> dir.list  rpm -q smeserver-zoneminder >/dev/null 2>&1 && cat <<'EOF' >>dir.list
460  /var/lib/zoneminder  /var/lib/zoneminder
461  /var/log/zoneminder  /var/log/zoneminder
462  /var/spool/zoneminder-upload  /var/spool/zoneminder-upload
# Line 364  EOF Line 490  EOF
490  #smeserver-sane  #smeserver-sane
491  #smeserver-usbdisksmanager  #smeserver-usbdisksmanager
492    
493  #we might get issue there with .rpmnew files  # we might get issue there with .rpmnew files
494  # but we need to get the same version as in db  # but we need to get the same version as in db
495    
496  #  for F in /usr/share/nextcloud/apps/*;do  #  for F in /usr/share/nextcloud/apps/*;do
497  #    rpm -qf $F >/dev/null 2>&1 || echo $F >> dir.list  #    rpm -qf "$F" >/dev/null 2>&1 || echo "$F" >> dir.list
498  #  done  #  done
499    
500    /sbin/e-smith/audittools/newrpms >/root/newrpms
501    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
502    cat </root/newrpms | grep @ | cut -d' ' -f1 | sed 's/.noarch//g' | sed 's/.x86_64//g' | sed 's/.i386//g' | sort >/root/rpmsextra
503    
   
 ## add here selection for test or live and stop services  
 /sbin/e-smith/audittools/newrpms > /root/newrpms  
 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  
 cat /root/newrpms|grep @ |cut -d' ' -f1|sed 's/.noarch//g'| sed 's/.x86_64//g'|sed 's/.i386//g'|sort >/root/rpmsextra  
 #ADD here  
504  mkdir -p /root/migratehelper/{yumDownload,lists}  mkdir -p /root/migratehelper/{yumDownload,lists}
505  # filter out in file per repo  
506  # run trhough all created files for /root/migratehelper/lists/RpmsPerRepos_*.list  # Filter out in file per repo
507  # and yum reinstall --downloadonly --downloaddir=/root/migratehelper/yumDownload # mayded followed by yum update --downloadonly --downloaddir=/root/migratehelper/yumDownload  
508  # or  yum install --downloadonly --downloaddir=/root/migratehelper/yumDownload --installroot=/root/migratehelper/ smeserver-yum --enablerepo=smeos,base --releasever=6  echo "Run through all created files for /root/migratehelper/lists/RpmsPerRepos_*.list"
509  # or after requiring yum-utils  (bug it seems to only download to current dir whatever you do:  echo "and"
510  # cd /root/migratehelper/yumDownload; yumdownloader install --downloadonly  --downloaddir=. smeserver-freepbx -y --diablerepo=* --enablerepo=$repo --releasever=6  echo "yum reinstall --downloadonly --downloaddir=/root/migratehelper/yumDownload"
511    echo "maybe followed by"
512  #### stop services so no changes occurs  echo "yum update --downloadonly --downloaddir=/root/migratehelper/yumDownload"
513  if [ -e /usr/lib/systemd/system/qmail.service ]; then  echo "or"
514    /usr/bin/systemctl stop qmail.service qpsmtpd.service sqpsmtpd.service ejabberd.service smb.service smbd.service nmbd.service httpd-e-smith.service  echo "yum install --downloadonly --downloaddir=/root/migratehelper/yumDownload --installroot=/root/migratehelper/ smeserver-yum --enablerepo=smeos,base --releasever=6"
515    echo "or after requiring yum-utils  (bug it seems to only download to current dir whatever you do:"
516    echo "cd /root/migratehelper/yumDownload; yumdownloader install --downloadonly --downloaddir=. smeserver-freepbx -y --disablerepo=* --enablerepo=\$repo --releasever=6"
517    
518    if [ $TEST = "n" ]; then
519      echo "Stopping Services and running backup"
520      echo "Test $TEST"
521      exit 1
522    
523      #### stop services so no changes occurs
524      if [ -e /usr/lib/systemd/system/qmail.service ]; then
525        /usr/bin/systemctl stop qmail.service qpsmtpd.service sqpsmtpd.service ejabberd.service smb.service smbd.service nmbd.service httpd-e-smith.service
526      else
527        sv d /service/qmail
528        sv d /service/qpsmtpd
529        sv d /service/sqpsmtpd
530        [ -e /service/ejabberd ] && sv d /service/ejabberd
531        sv d /service/smbd
532        sv d /service/httpd-e-smith
533      fi
534      
535      #### prebackup
536      signal-event pre-backup
537    
538      if [ ! -d /mnt/backup ]; then
539        mkdir -p /mnt/backup
540      fi
541    
542      tar cvzf /mnt/backup/smeserver.tgz -T dir.list --exclude-from exclude.list --xattrs
543      echo "Finished. Backup file is in /mnt/backup"
544      echo "All services stopped."
545      echo "Please copy the remaining files to the new server before you halt this server"
546    
547  else  else
548    sv d /service/qmail    echo "Test mode enabled - no backup run"
549    sv d /service/qpsmtpd    echo "Test $TEST"
550    sv d /service/sqpsmtpd    exit 0
551    [ -e /service/ejabberd ] && sv d /service/ejabberd  fi
552    sv d /service/smbd  
553    sv d /service/httpd-e-smith  exit 0
 fi  
 #### prebackup  
 signal-event pre-backup  
 tar cvzf /mnt/backup/smeserver.tgz -T dir.list  --exclude-from exclude.list --xattrs  


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

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