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