1 |
jpp |
1.1 |
#!/bin/bash |
2 |
|
|
|
3 |
jcrisp |
1.6 |
echo "#*************************************************************************# " |
4 |
|
|
echo "# Note we are NOT including >>" |
5 |
|
|
echo "# /home/e-smith/{files,shares} " |
6 |
|
|
echo "# /home/e-smith/db/mysql*/{daily,hourly}" |
7 |
|
|
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 |
jpp |
1.1 |
/etc/e-smith/templates-custom |
110 |
|
|
/etc/e-smith/templates-user-custom |
111 |
|
|
/etc/group |
112 |
|
|
/etc/gshadow |
113 |
|
|
/etc/passwd |
114 |
|
|
/etc/samba/secrets.tdb |
115 |
|
|
/etc/samba/smbpasswd |
116 |
|
|
/etc/shadow |
117 |
|
|
/etc/ssh |
118 |
|
|
/etc/sudoers |
119 |
|
|
/root |
120 |
|
|
/home/e-smith/Maildir |
121 |
|
|
/home/e-smith/home |
122 |
|
|
/home/e-smith/ssl.crt |
123 |
|
|
/home/e-smith/ssl.key |
124 |
|
|
/home/e-smith/dkim_keys |
125 |
|
|
/home/e-smith/db |
126 |
|
|
/var/lib/dhcpd/dhcpd.leases |
127 |
|
|
/var/log/qpsmtpd |
128 |
|
|
/var/log/sqpsmtpd |
129 |
|
|
/var/log/qmail |
130 |
|
|
/var/log/httpd/ |
131 |
|
|
/var/log/dovecot/ |
132 |
|
|
/var/log/squid/ |
133 |
|
|
/var/log/iptables/ |
134 |
|
|
/var/spool/mail/ |
135 |
|
|
/var/spool/spamd/ |
136 |
jpp |
1.5 |
/var/spool/cron/ |
137 |
jpp |
1.1 |
EOF |
138 |
|
|
|
139 |
jcrisp |
1.6 |
[ -e /etc/smbpasswd ] && cat <<'EOF' >>dir.list |
140 |
jpp |
1.3 |
/etc/smbpasswd |
141 |
|
|
EOF |
142 |
|
|
|
143 |
jcrisp |
1.6 |
[ -e /var/log/samba/samba_audit ] && cat <<'EOF' >>dir.list |
144 |
jpp |
1.1 |
/var/log/samba/samba_audit |
145 |
|
|
EOF |
146 |
|
|
|
147 |
jcrisp |
1.6 |
[ -e /etc/samba/schannel_store.tdb ] && cat <<'EOF' >>dir.list |
148 |
jpp |
1.5 |
/etc/samba/schannel_store.tdb |
149 |
|
|
EOF |
150 |
|
|
|
151 |
jcrisp |
1.6 |
[ -e /var/lib/samba/group_mapping.tdb ] && cat <<'EOF' >>dir.list |
152 |
jpp |
1.5 |
/var/lib/samba/group_mapping.tdb |
153 |
|
|
EOF |
154 |
|
|
|
155 |
jcrisp |
1.6 |
[ -e /var/lib/samba/account_policy.tdb ] && cat <<'EOF' >>dir.list |
156 |
jpp |
1.5 |
/var/lib/samba/account_policy.tdb |
157 |
|
|
EOF |
158 |
|
|
|
159 |
jcrisp |
1.6 |
[ -e /var/log/samba/samba_audit ] && cat <<'EOF' >>dir.list |
160 |
jpp |
1.5 |
/var/log/samba/samba_audit |
161 |
|
|
EOF |
162 |
|
|
|
163 |
jcrisp |
1.6 |
[ -e /var/service/qpsmtpd/config/dkimkeys/ ] && cat <<'EOF' >>dir.list |
164 |
jpp |
1.1 |
/var/service/qpsmtpd/config/dkimkeys/ |
165 |
|
|
EOF |
166 |
|
|
|
167 |
|
|
## add here inclusion from db key |
168 |
|
|
|
169 |
|
|
## exclude files |
170 |
|
|
cat <<EOF >exclude.list |
171 |
|
|
/home/e-smith/db/mysql/daily |
172 |
|
|
/home/e-smith/db/mysql/hourly |
173 |
|
|
/home/e-smith/db/mysql55/daily |
174 |
|
|
/home/e-smith/db/mysql55/hourly |
175 |
|
|
/home/e-smith/db/mysql57/daily |
176 |
|
|
/home/e-smith/db/mysql57/hourly |
177 |
|
|
/home/e-smith/files |
178 |
|
|
/home/e-smith/shares |
179 |
|
|
/etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/20LoadModule80PHP |
180 |
|
|
/etc/e-smith/templates-custom/etc/hosts.allow/sshd |
181 |
|
|
/etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/35SSL00Listen443 |
182 |
|
|
/etc/e-smith/templates-custom/etc/dhcpd.conf/25DomainNameServers |
183 |
|
|
/etc/e-smith/templates-custom/etc/dhcpd.conf/25LeaseTimeDefault |
184 |
|
|
/etc/e-smith/templates-custom/etc/dhcpd.conf/25LeaseTimeMax |
185 |
|
|
/etc/e-smith/templates-custom/etc/dhcpd.conf/25Routers |
186 |
|
|
EOF |
187 |
|
|
|
188 |
|
|
## add here exclusion from db key |
189 |
jcrisp |
1.6 |
# Added -print0 here - also needs -0 on xargs |
190 |
|
|
# https://github.com/koalaman/shellcheck/wiki/SC2038 |
191 |
|
|
# 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 |
jpp |
1.2 |
# search for local dir script added |
194 |
jcrisp |
1.6 |
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 |
196 |
|
|
find /etc/cron.* -type f -print0 | xargs -0 -I % sh -c "rpm -qf % 2>&1 > /dev/null || echo % >> dir.list" |
197 |
jpp |
1.1 |
# search for udev rules not owned by a rpm ! oucl add an option there in case you change of hardware |
198 |
jcrisp |
1.6 |
find /etc/udev/rules.d/ -type f -print0 | xargs -0 -I % sh -c "rpm -qf % 2>&1 > /dev/null || echo % >> dir.list" |
199 |
jpp |
1.2 |
# search for spamassassin user created config |
200 |
jcrisp |
1.6 |
find /etc/mail/spamassassin -maxdepth 1 -type f -print0 | xargs -0 -I % sh -c "rpm -qf % 2>&1 > /dev/null || echo % >> dir.list" |
201 |
jpp |
1.1 |
|
202 |
|
|
################## |
203 |
|
|
# |
204 |
|
|
# here starts the magic |
205 |
jcrisp |
1.6 |
# we backup each known contribs folder |
206 |
jpp |
1.1 |
# |
207 |
|
|
################## |
208 |
jcrisp |
1.6 |
#smeserver-awstats.noarch |
209 |
jpp |
1.1 |
# data will be in /home/e-smith/files/users/admin |
210 |
|
|
# we only backup the config files |
211 |
jcrisp |
1.6 |
rpm -q smeserver-awstats >/dev/null 2>&1 && cat <<'EOF' >>dir.list |
212 |
jpp |
1.1 |
/etc/e-smith/web/panels/manager/cgi-bin/.awstats/ |
213 |
|
|
EOF |
214 |
jcrisp |
1.6 |
# see with Daniel if they have a specific config |
215 |
jpp |
1.1 |
#rpm -q awstats >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
216 |
|
|
#/var/lib/awstats |
217 |
|
|
#EOF |
218 |
|
|
#for those we assume you handle yourself the backup or the pools in /var/lib/BackupPC |
219 |
jcrisp |
1.6 |
rpm -q smeserver-BackupPC >/dev/null 2>&1 && cat <<'EOF' >>dir.list |
220 |
jpp |
1.1 |
/etc/BackupPC |
221 |
|
|
EOF |
222 |
jcrisp |
1.6 |
rpm -q smeserver-BackupPC4 >/dev/null 2>&1 && cat <<'EOF' >>dir.list |
223 |
jpp |
1.1 |
/etc/BackupPC |
224 |
|
|
EOF |
225 |
jcrisp |
1.6 |
rpm -q smeserver-bandwidthd >/dev/null 2>&1 && cat <<'EOF' >>dir.list |
226 |
jpp |
1.1 |
/var/www/bandwidthd/ |
227 |
|
|
EOF |
228 |
|
|
#smeserver-clamav-unofficial-sigs and clamav-unofficial-sigs |
229 |
jcrisp |
1.6 |
rpm -q smeserver-clamav-unofficial-sigs >/dev/null 2>&1 && cat <<'EOF' >>dir.list |
230 |
jpp |
1.1 |
/var/lib/clamav-unofficial-sigs/ |
231 |
|
|
EOF |
232 |
|
|
#smeserver-dansguardian smeserver-dansguardian-panel |
233 |
jcrisp |
1.6 |
rpm -q smeserver-dansguardian >/dev/null 2>&1 && cat <<'EOF' >>dir.list |
234 |
jpp |
1.1 |
/etc/dansguardian/ |
235 |
|
|
EOF |
236 |
|
|
#smeserver-denyhosts |
237 |
jcrisp |
1.6 |
rpm -q smeserver-denyhosts >/dev/null 2>&1 && cat <<'EOF' >>dir.list |
238 |
jpp |
1.1 |
/var/lib/denyhosts/ |
239 |
|
|
/etc/hosts.deny_ssh |
240 |
|
|
/etc/hosts.deny_ssh.purge.bak |
241 |
|
|
EOF |
242 |
jcrisp |
1.6 |
rpm -q smeserver-dl >/dev/null 2>&1 && cat <<'EOF' >>dir.list |
243 |
jpp |
1.1 |
/var/lib/dl/ |
244 |
|
|
EOF |
245 |
jcrisp |
1.6 |
rpm -q dokuwiki >/dev/null 2>&1 && cat <<'EOF' >>dir.list |
246 |
jpp |
1.1 |
/etc/dokuwiki/acl.auth.php |
247 |
|
|
/etc/dokuwiki/acronyms.conf |
248 |
|
|
/etc/dokuwiki/entities.conf |
249 |
|
|
/etc/dokuwiki/interwiki.conf |
250 |
|
|
/etc/dokuwiki/local.php |
251 |
|
|
/etc/dokuwiki/plugins.local.php |
252 |
|
|
/etc/dokuwiki/scheme.conf |
253 |
|
|
/var/lib/dokuwiki/data/attic |
254 |
|
|
/var/lib/dokuwiki/data/index |
255 |
|
|
/var/lib/dokuwiki/data/media |
256 |
|
|
/var/lib/dokuwiki/data/media_attic |
257 |
|
|
/var/lib/dokuwiki/data/media_meta |
258 |
|
|
/var/lib/dokuwiki/data/meta |
259 |
|
|
/var/lib/dokuwiki/data/pages |
260 |
|
|
EOF |
261 |
jcrisp |
1.6 |
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 |
263 |
jpp |
1.1 |
done |
264 |
|
|
|
265 |
jpp |
1.3 |
#rpm -q smeserver-dovecot >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
266 |
jcrisp |
1.6 |
[ -e /etc/dovecot/sharemailbox ] && cat <<'EOF' >>dir.list |
267 |
jpp |
1.1 |
/etc/dovecot/sharemailbox/ |
268 |
|
|
EOF |
269 |
|
|
|
270 |
|
|
#smeserver-durep |
271 |
jcrisp |
1.6 |
rpm -q smeserver-durep >/dev/null 2>&1 && cat <<'EOF' >>dir.list |
272 |
jpp |
1.1 |
/var/lib/durep |
273 |
|
|
EOF |
274 |
|
|
#smeserver-ezmlm-web |
275 |
jcrisp |
1.6 |
rpm -q smeserver-ezmlm-web >/dev/null 2>&1 && cat <<'EOF' >>dir.list |
276 |
jpp |
1.1 |
/home/e-smith/files/ezmlm |
277 |
|
|
EOF |
278 |
jcrisp |
1.6 |
[ -e /var/lib/phone ] && cat <<'EOF' >>dir.list |
279 |
jpp |
1.1 |
/var/lib/phone |
280 |
|
|
EOF |
281 |
jcrisp |
1.6 |
rpm -q smeserver-freepbx >/dev/null 2>&1 && cat <<'EOF' >>dir.list |
282 |
jpp |
1.1 |
/opt/freepbx |
283 |
|
|
/var/lib/asterisk/ |
284 |
|
|
/etc/asterisk |
285 |
|
|
/var/spool/asterisk/ |
286 |
|
|
/var/log/asterisk |
287 |
|
|
/usr/local/sbin/amportal |
288 |
|
|
/usr/local/sbin/fwconsole |
289 |
|
|
/usr/sbin/amportal |
290 |
|
|
/usr/sbin/fwconsole |
291 |
|
|
EOF |
292 |
jcrisp |
1.6 |
# smeserver-fail2ban |
293 |
jpp |
1.1 |
if [ -d /etc/fail2ban/action.d ]; then |
294 |
jcrisp |
1.6 |
for F in /etc/fail2ban/action.d/*; do |
295 |
|
|
rpm -qf /etc/fail2ban/action.d/"$F" >/dev/null 2>&1 || echo /etc/fail2ban/action.d/"$F" >>dir.list |
296 |
jpp |
1.1 |
done |
297 |
|
|
fi |
298 |
|
|
if [ -d /etc/fail2ban/fail2ban.d ]; then |
299 |
jcrisp |
1.6 |
for F in /etc/fail2ban/fail2ban.d*; do |
300 |
|
|
rpm -qf /etc/fail2ban/fail2ban.d/"$F" >/dev/null 2>&1 || echo /etc/fail2ban/fail2ban.d/"$F" >>dir.list |
301 |
jpp |
1.1 |
done |
302 |
|
|
fi |
303 |
|
|
if [ -d /etc/fail2ban/filter.d ]; then |
304 |
jcrisp |
1.6 |
for F in /etc/fail2ban/filter.d/*; do |
305 |
|
|
rpm -qf /etc/fail2ban/filter.d/"$F" >/dev/null 2>&1 || echo /etc/fail2ban/filter.d/"$F" >>dir.list |
306 |
jpp |
1.1 |
done |
307 |
|
|
fi |
308 |
|
|
if [ -d /etc/fail2ban/jail.d ]; then |
309 |
jcrisp |
1.6 |
for F in /etc/fail2ban/jail.d/*; do |
310 |
|
|
rpm -qf /etc/fail2ban/jail.d/"$F" >/dev/null 2>&1 || echo /etc/fail2ban/jail.d/"$F" >>dir.list |
311 |
jpp |
1.1 |
done |
312 |
|
|
fi |
313 |
jcrisp |
1.6 |
rpm -q smeserver-grr >/dev/null 2>&1 && cat <<'EOF' >>dir.list |
314 |
jpp |
1.1 |
/usr/share/grr/images/ |
315 |
|
|
EOF |
316 |
jcrisp |
1.6 |
rpm -q ipasserelle-im >/dev/null 2>&1 && cat <<'EOF' >>dir.list |
317 |
jpp |
1.1 |
/var/lib/ejabberd/ |
318 |
|
|
/var/log/ejabberd.run |
319 |
|
|
EOF |
320 |
|
|
#smeserver-isoqlog |
321 |
jcrisp |
1.6 |
rpm -q smeserver-isoqlog >/dev/null 2>&1 && cat <<'EOF' >>dir.list |
322 |
jpp |
1.1 |
/var/lib/qmailtools/isoqlog/htdocs/ |
323 |
|
|
EOF |
324 |
jcrisp |
1.6 |
rpm -q smeserver-jappix >/dev/null 2>&1 && cat <<'EOF' >>dir.list |
325 |
jpp |
1.1 |
/var/lib/jappix/ |
326 |
|
|
/var/log/jappix |
327 |
|
|
EOF |
328 |
jcrisp |
1.6 |
rpm -q smeserver-lemonldap-ng >/dev/null 2>&1 && cat <<'EOF' >>dir.list |
329 |
jpp |
1.1 |
/var/lib/lemonldap-ng/conf |
330 |
|
|
/var/lib/lemonldap-ng/notifications |
331 |
|
|
EOF |
332 |
|
|
#smeserver-letsencrypt |
333 |
jpp |
1.3 |
#rpm -q smeserver-letsencrypt >/dev/null 2>&1 && cat <<'EOF' >> dir.list |
334 |
jcrisp |
1.6 |
[ -d /etc/letsencrypt.sh/ ] && cat <<'EOF' >>dir.list |
335 |
jpp |
1.1 |
/etc/letsencrypt.sh/ |
336 |
jpp |
1.3 |
EOF |
337 |
jcrisp |
1.6 |
[ -d /etc/dehydrated/ ] && cat <<'EOF' >>dir.list |
338 |
jpp |
1.1 |
/etc/dehydrated/ |
339 |
|
|
EOF |
340 |
jpp |
1.3 |
|
341 |
jcrisp |
1.6 |
rpm -q smeserver-limesurvey >/dev/null 2>&1 && cat <<'EOF' >>dir.list |
342 |
jpp |
1.1 |
/var/lib/limesurvey/uploads |
343 |
|
|
EOF |
344 |
jcrisp |
1.6 |
rpm -q ipasserelle-listes >/dev/null 2>&1 && cat <<'EOF' >>dir.list |
345 |
jpp |
1.1 |
/var/lib/mailman/ |
346 |
|
|
/usr/lib/mailman/aliases/ |
347 |
|
|
EOF |
348 |
|
|
if [ -d /usr/share/mozilla-mcd/ ]; then |
349 |
jcrisp |
1.6 |
for F in /usr/share/mozilla-mcd/*; do |
350 |
|
|
rpm -qf "$F" >/dev/null 2>&1 || echo "$F" >>dir.list |
351 |
jpp |
1.1 |
done |
352 |
|
|
fi |
353 |
jcrisp |
1.6 |
rpm -q smeserver-madsonic >/dev/null 2>&1 && cat <<'EOF' >>dir.list |
354 |
jpp |
1.1 |
/var/madsonic/db/ |
355 |
|
|
/var/madsonic/madsonic.properties |
356 |
|
|
/var/madsonic/madsonic.log |
357 |
|
|
/var/madsonic/madsonic_sh.log |
358 |
|
|
EOF |
359 |
jcrisp |
1.6 |
rpm -q smeserver-mailman >/dev/null 2>&1 && cat <<'EOF' >>dir.list |
360 |
jpp |
1.1 |
/var/lib/mailman/ |
361 |
|
|
/usr/lib/mailman/aliases/ |
362 |
|
|
EOF |
363 |
jcrisp |
1.6 |
rpm -q smeserver-nextcloud >/dev/null 2>&1 && cat <<'EOF' >>dir.list |
364 |
jpp |
1.1 |
/usr/share/nextcloud/ |
365 |
|
|
EOF |
366 |
jcrisp |
1.6 |
rpm -q smeserver-ntop >/dev/null 2>&1 && cat <<'EOF' >>dir.list |
367 |
jpp |
1.1 |
/var/lib/ntop/ |
368 |
|
|
EOF |
369 |
jcrisp |
1.6 |
rpm -q phpki >/dev/null 2>&1 && cat <<'EOF' >>dir.list |
370 |
jpp |
1.1 |
/opt/phpki/phpki-store/ |
371 |
|
|
/opt/phpki/html/config.php |
372 |
|
|
EOF |
373 |
jcrisp |
1.6 |
rpm -q smeserver-openvpn-bridge >/dev/null 2>&1 && cat <<'EOF' >>dir.list |
374 |
jpp |
1.1 |
/etc/openvpn/bridge/priv |
375 |
|
|
/etc/openvpn/bridge/pub |
376 |
|
|
/var/log/openvpn-bridge |
377 |
|
|
EOF |
378 |
jcrisp |
1.6 |
rpm -q smeserver-openvpn-s2s >/dev/null 2>&1 && cat <<'EOF' >>dir.list |
379 |
jpp |
1.1 |
/etc/openvpn/s2s/priv |
380 |
|
|
/etc/openvpn/s2s/pub |
381 |
|
|
/var/log/openvpn-s2s |
382 |
|
|
EOF |
383 |
jcrisp |
1.6 |
rpm -q smeserver-openvpn-routed >/dev/null 2>&1 && cat <<'EOF' >>dir.list |
384 |
jpp |
1.1 |
/etc/openvpn/routed/priv |
385 |
|
|
/etc/openvpn/routed/pub |
386 |
|
|
/var/log/openvpn-routed |
387 |
|
|
EOF |
388 |
jcrisp |
1.6 |
rpm -q smeserver-phpki >/dev/null 2>&1 && cat <<'EOF' >>dir.list |
389 |
jpp |
1.1 |
/opt/phpki/ |
390 |
|
|
EOF |
391 |
jcrisp |
1.6 |
rpm -q smeserver-phpki-ng >/dev/null 2>&1 && cat <<'EOF' >>dir.list |
392 |
jpp |
1.1 |
/opt/phpki/ |
393 |
|
|
EOF |
394 |
jcrisp |
1.6 |
rpm -q pydio >/dev/null 2>&1 && cat <<'EOF' >>dir.list |
395 |
jpp |
1.1 |
/var/lib/pydio/files |
396 |
|
|
/var/lib/pydio/personal |
397 |
|
|
/var/lib/pydio/public |
398 |
|
|
/var/log/pydio |
399 |
|
|
EOF |
400 |
|
|
|
401 |
jcrisp |
1.6 |
rpm -q smeserver-sarg >/dev/null 2>&1 && cat <<'EOF' >>dir.list |
402 |
jpp |
1.1 |
/var/www/sarg/ |
403 |
|
|
EOF |
404 |
|
|
#smeserver-sme8admin |
405 |
jcrisp |
1.6 |
rpm -q smeserver-sme8admin >/dev/null 2>&1 && cat <<'EOF' >>dir.list |
406 |
jpp |
1.1 |
/var/lib/sme8admin/ |
407 |
|
|
EOF |
408 |
|
|
#smeserver-sme9admin |
409 |
jcrisp |
1.6 |
rpm -q smeserver-sme9admin >/dev/null 2>&1 && cat <<'EOF' >>dir.list |
410 |
jpp |
1.1 |
/var/lib/sme9admin/ |
411 |
|
|
EOF |
412 |
|
|
#smeserver-sysmon |
413 |
jcrisp |
1.6 |
rpm -q smeserver-sysmon >/dev/null 2>&1 && cat <<'EOF' >>dir.list |
414 |
jpp |
1.1 |
/var/lib/rrd/ |
415 |
|
|
EOF |
416 |
jcrisp |
1.6 |
rpm -q smeserver-tftp-server >/dev/null 2>&1 && cat <<'EOF' >>dir.list |
417 |
jpp |
1.1 |
/tftpboot |
418 |
|
|
EOF |
419 |
jcrisp |
1.6 |
rpm -q smeserver-transmission >/dev/null 2>&1 && cat <<'EOF' >>dir.list |
420 |
jpp |
1.1 |
/var/lib/transmission/Downloads |
421 |
|
|
EOF |
422 |
jcrisp |
1.6 |
rpm -q smeserver-unifi >/dev/null 2>&1 && cat <<'EOF' >>dir.list |
423 |
jpp |
1.1 |
/opt/UniFi |
424 |
|
|
/opt/UniFi_bak |
425 |
|
|
EOF |
426 |
jcrisp |
1.6 |
rpm -q smeserver-xinetd >/dev/null 2>&1 && cat <<'EOF' >>dir.list |
427 |
jpp |
1.1 |
/etc/rsyncd.conf |
428 |
|
|
/etc/xinetd.d/rsync |
429 |
|
|
/etc/logrotate.d/rsyncd |
430 |
|
|
EOF |
431 |
jcrisp |
1.6 |
rpm -q smeserver-xt_geoip >/dev/null 2>&1 && cat <<'EOF' >>dir.list |
432 |
jpp |
1.1 |
/usr/share/xt_geoip/BE/ |
433 |
|
|
/usr/share/xt_geoip/LE/ |
434 |
|
|
/var/lib/xt_geoip/ |
435 |
|
|
EOF |
436 |
jcrisp |
1.6 |
rpm -q smeserver-webfilter >/dev/null 2>&1 && cat <<'EOF' >>dir.list |
437 |
jpp |
1.1 |
/var/squidGuard/blacklists/ |
438 |
|
|
EOF |
439 |
|
|
#smeserver-webshares |
440 |
jcrisp |
1.6 |
rpm -q smeserver-webshares >/dev/null 2>&1 && cat <<'EOF' >>dir.list |
441 |
jpp |
1.1 |
/opt/webshare |
442 |
|
|
EOF |
443 |
|
|
# smeserver-zabbix-server smeserver-zabbix-agent smeserver-zabbix-proxy |
444 |
|
|
if [ -d /etc/zabbix ]; then |
445 |
jcrisp |
1.6 |
for F in /etc/zabbix/*; do |
446 |
|
|
rpm -qf "$F" >/dev/null 2>&1 || echo "$F" >>dir.list |
447 |
jpp |
1.1 |
done |
448 |
|
|
fi |
449 |
|
|
if [ -d /etc/zabbix/zabbix_agentd.conf.d ]; then |
450 |
jcrisp |
1.6 |
for F in /etc/zabbix/zabbix_agentd.conf.d/*; do |
451 |
|
|
rpm -qf "$F" >/dev/null 2>&1 || echo "$F" >>dir.list |
452 |
jpp |
1.1 |
done |
453 |
|
|
fi |
454 |
|
|
if [ -d /var/lib/zabbix/bin ]; then |
455 |
jcrisp |
1.6 |
for F in /var/lib/zabbix/bin/*; do |
456 |
|
|
rpm -qf "$F" >/dev/null 2>&1 || echo "$F" >>dir.list |
457 |
jpp |
1.1 |
done |
458 |
|
|
fi |
459 |
jcrisp |
1.6 |
rpm -q smeserver-zoneminder >/dev/null 2>&1 && cat <<'EOF' >>dir.list |
460 |
jpp |
1.1 |
/var/lib/zoneminder |
461 |
|
|
/var/log/zoneminder |
462 |
|
|
/var/spool/zoneminder-upload |
463 |
|
|
EOF |
464 |
|
|
|
465 |
|
|
#contribs we are aware of, but NOTHING TO DO |
466 |
|
|
#smeserver-email-management |
467 |
|
|
#smeserver-geoip |
468 |
|
|
#smeserver-kronolith |
469 |
|
|
#smeserver-lazy_admin_tools |
470 |
|
|
#smeserver-learn |
471 |
|
|
#smeserver-mailsorting |
472 |
|
|
#smeserver-mailstats |
473 |
|
|
#smeserver-mod_dav |
474 |
|
|
#smeserver-nag |
475 |
|
|
#smeserver-php-fpm |
476 |
|
|
#smeserver-php-scl |
477 |
|
|
#smeserver-phpldapadmin. |
478 |
|
|
#smeserver-phpsysinfo |
479 |
|
|
#smeserver-qmHandle |
480 |
|
|
#smeserver-remoteuseraccess |
481 |
|
|
#smeserver-userpanel |
482 |
|
|
#smeserver-userpanels |
483 |
|
|
#smeserver-vacation |
484 |
|
|
#smeserver-wbl |
485 |
|
|
#smeserver-webapps-common |
486 |
|
|
#smeserver-webhosting |
487 |
|
|
#smeserver-bridge-interface |
488 |
|
|
#smeserver-ddclient |
489 |
|
|
#smeserver-mediatomb |
490 |
|
|
#smeserver-sane |
491 |
|
|
#smeserver-usbdisksmanager |
492 |
|
|
|
493 |
jcrisp |
1.6 |
# we might get issue there with .rpmnew files |
494 |
|
|
# but we need to get the same version as in db |
495 |
jpp |
1.1 |
|
496 |
|
|
# for F in /usr/share/nextcloud/apps/*;do |
497 |
jcrisp |
1.6 |
# rpm -qf "$F" >/dev/null 2>&1 || echo "$F" >> dir.list |
498 |
jpp |
1.1 |
# done |
499 |
|
|
|
500 |
jcrisp |
1.6 |
/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 |
jpp |
1.1 |
|
504 |
jcrisp |
1.6 |
mkdir -p /root/migratehelper/{yumDownload,lists} |
505 |
|
|
|
506 |
|
|
# Filter out in file per repo |
507 |
|
|
|
508 |
|
|
echo "Run through all created files for /root/migratehelper/lists/RpmsPerRepos_*.list" |
509 |
|
|
echo "and" |
510 |
|
|
echo "yum reinstall --downloadonly --downloaddir=/root/migratehelper/yumDownload" |
511 |
|
|
echo "maybe followed by" |
512 |
|
|
echo "yum update --downloadonly --downloaddir=/root/migratehelper/yumDownload" |
513 |
|
|
echo "or" |
514 |
|
|
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 |
jcrisp |
1.7 |
|
521 |
|
|
# uncomment to test Test and prevent backup running |
522 |
|
|
# echo "Test mode $TEST" |
523 |
|
|
# exit 1 |
524 |
jcrisp |
1.6 |
|
525 |
|
|
#### stop services so no changes occurs |
526 |
|
|
if [ -e /usr/lib/systemd/system/qmail.service ]; then |
527 |
|
|
/usr/bin/systemctl stop qmail.service qpsmtpd.service sqpsmtpd.service ejabberd.service smb.service smbd.service nmbd.service httpd-e-smith.service |
528 |
|
|
else |
529 |
|
|
sv d /service/qmail |
530 |
|
|
sv d /service/qpsmtpd |
531 |
|
|
sv d /service/sqpsmtpd |
532 |
|
|
[ -e /service/ejabberd ] && sv d /service/ejabberd |
533 |
|
|
sv d /service/smbd |
534 |
|
|
sv d /service/httpd-e-smith |
535 |
|
|
fi |
536 |
|
|
|
537 |
|
|
#### prebackup |
538 |
|
|
signal-event pre-backup |
539 |
|
|
|
540 |
|
|
if [ ! -d /mnt/backup ]; then |
541 |
|
|
mkdir -p /mnt/backup |
542 |
|
|
fi |
543 |
|
|
|
544 |
|
|
tar cvzf /mnt/backup/smeserver.tgz -T dir.list --exclude-from exclude.list --xattrs |
545 |
|
|
echo "Finished. Backup file is in /mnt/backup" |
546 |
|
|
echo "All services stopped." |
547 |
|
|
echo "Please copy the remaining files to the new server before you halt this server" |
548 |
jpp |
1.1 |
|
549 |
|
|
else |
550 |
jcrisp |
1.6 |
echo "Test mode enabled - no backup run" |
551 |
jcrisp |
1.7 |
echo "Test mode $TEST" |
552 |
jcrisp |
1.6 |
exit 0 |
553 |
|
|
fi |
554 |
|
|
|
555 |
|
|
exit 0 |