|
@@ -55,18 +55,18 @@ fi
|
55
|
55
|
|
56
|
56
|
|
57
|
57
|
function update_domains {
|
58
|
|
- MICROBLOG_DOMAIN_NAME='microblog'
|
59
|
|
- if grep -q "GNU Social domain" $COMPLETION_FILE; then
|
60
|
|
- MICROBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "GNU Social domain" | awk -F ':' '{print $2}')
|
61
|
|
- fi
|
62
|
|
- HUBZILLA_DOMAIN_NAME='hubzilla'
|
63
|
|
- if grep -q "Hubzilla domain" $COMPLETION_FILE; then
|
64
|
|
- HUBZILLA_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Hubzilla domain" | awk -F ':' '{print $2}')
|
65
|
|
- fi
|
66
|
|
- FULLBLOG_DOMAIN_NAME='blog'
|
67
|
|
- if grep -q "Blog domain" $COMPLETION_FILE; then
|
68
|
|
- FULLBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Blog domain" | awk -F ':' '{print $2}')
|
69
|
|
- fi
|
|
58
|
+ MICROBLOG_DOMAIN_NAME='microblog'
|
|
59
|
+ if grep -q "GNU Social domain" $COMPLETION_FILE; then
|
|
60
|
+ MICROBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "GNU Social domain" | awk -F ':' '{print $2}')
|
|
61
|
+ fi
|
|
62
|
+ HUBZILLA_DOMAIN_NAME='hubzilla'
|
|
63
|
+ if grep -q "Hubzilla domain" $COMPLETION_FILE; then
|
|
64
|
+ HUBZILLA_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Hubzilla domain" | awk -F ':' '{print $2}')
|
|
65
|
+ fi
|
|
66
|
+ FULLBLOG_DOMAIN_NAME='blog'
|
|
67
|
+ if grep -q "Blog domain" $COMPLETION_FILE; then
|
|
68
|
+ FULLBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Blog domain" | awk -F ':' '{print $2}')
|
|
69
|
+ fi
|
70
|
70
|
}
|
71
|
71
|
|
72
|
72
|
function mount_drive {
|
|
@@ -347,6 +347,72 @@ function remove_backup_directory {
|
347
|
347
|
fi
|
348
|
348
|
}
|
349
|
349
|
|
|
350
|
+function prepare_directories {
|
|
351
|
+ # Some miscellaneous preparation for backing up directories
|
|
352
|
+ if [ -d /home/git/go/src/github.com/gogits ]; then
|
|
353
|
+ mv /home/git/gogs-repositories/*.git /home/git/gogs-repositories/$ADMIN_USERNAME
|
|
354
|
+ fi
|
|
355
|
+ if [ -d /var/lib/tox-bootstrapd ]; then
|
|
356
|
+ cp /etc/tox-bootstrapd.conf /var/lib/tox-bootstrapd
|
|
357
|
+ if [ -d /var/lib/tox-bootstrapd/Maildir ]; then
|
|
358
|
+ rm -rf /var/lib/tox-bootstrapd/Maildir
|
|
359
|
+ fi
|
|
360
|
+ fi
|
|
361
|
+}
|
|
362
|
+
|
|
363
|
+function backup_configuration {
|
|
364
|
+ echo $"Backing up ${PROJECT_NAME} configuration files"
|
|
365
|
+ if [ ! -d /root/tempbackupconfig ]; then
|
|
366
|
+ mkdir -p /root/tempbackupconfig
|
|
367
|
+ fi
|
|
368
|
+ cp -f $CONFIG_FILE /root/tempbackupconfig
|
|
369
|
+ cp -f $COMPLETION_FILE /root/tempbackupconfig
|
|
370
|
+ backup_directory_to_usb /root/tempbackupconfig config
|
|
371
|
+}
|
|
372
|
+
|
|
373
|
+function backup_admin_readme {
|
|
374
|
+ if [ -f /home/$ADMIN_USERNAME/README ]; then
|
|
375
|
+ echo $"Backing up README"
|
|
376
|
+ if [ ! -d /home/$ADMIN_USERNAME/tempbackup ]; then
|
|
377
|
+ mkdir -p /home/$ADMIN_USERNAME/tempbackup
|
|
378
|
+ fi
|
|
379
|
+ cp -f /home/$ADMIN_USERNAME/README /home/$ADMIN_USERNAME/tempbackup
|
|
380
|
+ backup_directory_to_usb /home/$ADMIN_USERNAME/tempbackup readme
|
|
381
|
+ fi
|
|
382
|
+}
|
|
383
|
+
|
|
384
|
+function backup_voip {
|
|
385
|
+ if [ -f /etc/mumble-server.ini ]; then
|
|
386
|
+ echo $"Backing up VoIP settings"
|
|
387
|
+ if [ ! -d /root/tempvoipbackup ]; then
|
|
388
|
+ mkdir -p /root/tempvoipbackup
|
|
389
|
+ fi
|
|
390
|
+ cp -f /etc/mumble-server.ini /root/tempvoipbackup
|
|
391
|
+ cp -f /var/lib/mumble-server/mumble-server.sqlite /root/tempvoipbackup
|
|
392
|
+ cp -f /etc/sipwitch.conf /root/tempvoipbackup
|
|
393
|
+ backup_directory_to_usb /root/tempvoipbackup voip
|
|
394
|
+ fi
|
|
395
|
+}
|
|
396
|
+
|
|
397
|
+function backup_mariadb {
|
|
398
|
+ if [ ${#DATABASE_PASSWORD} -gt 1 ]; then
|
|
399
|
+ if [ ! -d /root/tempmariadb ]; then
|
|
400
|
+ mkdir /root/tempmariadb
|
|
401
|
+ fi
|
|
402
|
+ mysqldump --password="$DATABASE_PASSWORD" mysql user > /root/tempmariadb/mysql.sql
|
|
403
|
+ if [ ! -s /root/tempmariadb/mysql.sql ]; then
|
|
404
|
+ echo $"Unable to backup mysql settings"
|
|
405
|
+ rm -rf /root/tempmariadb
|
|
406
|
+ umount $USB_MOUNT
|
|
407
|
+ rm -rf $USB_MOUNT
|
|
408
|
+ exit 8
|
|
409
|
+ fi
|
|
410
|
+ echo "$DATABASE_PASSWORD" > /root/tempmariadb/db
|
|
411
|
+ chmod 400 /root/tempmariadb/db
|
|
412
|
+ backup_directory_to_usb /root/tempmariadb mariadb
|
|
413
|
+ fi
|
|
414
|
+}
|
|
415
|
+
|
350
|
416
|
# has the remove option been set ?
|
351
|
417
|
remove_option=$2
|
352
|
418
|
if [[ $1 == "remove" ]]; then
|
|
@@ -359,68 +425,12 @@ make_backup_directory
|
359
|
425
|
check_storage_space_remaining
|
360
|
426
|
update_domains
|
361
|
427
|
backup_users
|
362
|
|
-
|
363
|
|
-if [ -d /home/git/go/src/github.com/gogits ]; then
|
364
|
|
- mv /home/git/gogs-repositories/*.git /home/git/gogs-repositories/$ADMIN_USERNAME
|
365
|
|
-fi
|
366
|
|
-if [ -d /var/lib/tox-bootstrapd ]; then
|
367
|
|
- cp /etc/tox-bootstrapd.conf /var/lib/tox-bootstrapd
|
368
|
|
- if [ -d /var/lib/tox-bootstrapd/Maildir ]; then
|
369
|
|
- rm -rf /var/lib/tox-bootstrapd/Maildir
|
370
|
|
- fi
|
371
|
|
-fi
|
372
|
|
-
|
|
428
|
+prepare_directories
|
373
|
429
|
backup_directories
|
374
|
|
-
|
375
|
|
-# configuration files
|
376
|
|
-echo $"Backing up ${PROJECT_NAME} configuration files"
|
377
|
|
-if [ ! -d /root/tempbackupconfig ]; then
|
378
|
|
- mkdir -p /root/tempbackupconfig
|
379
|
|
-fi
|
380
|
|
-cp -f $CONFIG_FILE /root/tempbackupconfig
|
381
|
|
-cp -f $COMPLETION_FILE /root/tempbackupconfig
|
382
|
|
-backup_directory_to_usb /root/tempbackupconfig config
|
383
|
|
-
|
384
|
|
-# Backup admin user README file
|
385
|
|
-if [ -f /home/$ADMIN_USERNAME/README ]; then
|
386
|
|
- echo $"Backing up README"
|
387
|
|
- if [ ! -d /home/$ADMIN_USERNAME/tempbackup ]; then
|
388
|
|
- mkdir -p /home/$ADMIN_USERNAME/tempbackup
|
389
|
|
- fi
|
390
|
|
- cp -f /home/$ADMIN_USERNAME/README /home/$ADMIN_USERNAME/tempbackup
|
391
|
|
- backup_directory_to_usb /home/$ADMIN_USERNAME/tempbackup readme
|
392
|
|
-fi
|
393
|
|
-
|
394
|
|
-# Backup VoIP settings
|
395
|
|
-if [ -f /etc/mumble-server.ini ]; then
|
396
|
|
- echo $"Backing up VoIP settings"
|
397
|
|
- if [ ! -d /root/tempvoipbackup ]; then
|
398
|
|
- mkdir -p /root/tempvoipbackup
|
399
|
|
- fi
|
400
|
|
- cp -f /etc/mumble-server.ini /root/tempvoipbackup
|
401
|
|
- cp -f /var/lib/mumble-server/mumble-server.sqlite /root/tempvoipbackup
|
402
|
|
- cp -f /etc/sipwitch.conf /root/tempvoipbackup
|
403
|
|
- backup_directory_to_usb /root/tempvoipbackup voip
|
404
|
|
-fi
|
405
|
|
-
|
406
|
|
-# MariaDB settings
|
407
|
|
-if [ ${#DATABASE_PASSWORD} -gt 1 ]; then
|
408
|
|
- if [ ! -d /root/tempmariadb ]; then
|
409
|
|
- mkdir /root/tempmariadb
|
410
|
|
- fi
|
411
|
|
- mysqldump --password="$DATABASE_PASSWORD" mysql user > /root/tempmariadb/mysql.sql
|
412
|
|
- if [ ! -s /root/tempmariadb/mysql.sql ]; then
|
413
|
|
- echo $"Unable to backup mysql settings"
|
414
|
|
- rm -rf /root/tempmariadb
|
415
|
|
- umount $USB_MOUNT
|
416
|
|
- rm -rf $USB_MOUNT
|
417
|
|
- exit 8
|
418
|
|
- fi
|
419
|
|
- echo "$DATABASE_PASSWORD" > /root/tempmariadb/db
|
420
|
|
- chmod 400 /root/tempmariadb/db
|
421
|
|
- backup_directory_to_usb /root/tempmariadb mariadb
|
422
|
|
-fi
|
423
|
|
-
|
|
430
|
+backup_configuration
|
|
431
|
+backup_admin_readme
|
|
432
|
+backup_voip
|
|
433
|
+backup_mariadb
|
424
|
434
|
unmount_drive
|
425
|
435
|
|
426
|
436
|
exit 0
|