Kaynağa Gözat

Local backup function for blog

Bob Mottram 8 yıl önce
ebeveyn
işleme
d919518eb9
No account linked to committer's email

+ 22
- 2
src/freedombone-app-blog Dosyayı Görüntüle

@@ -47,11 +47,31 @@ function upgrade_blog {
47 47
 }
48 48
 
49 49
 function backup_local_blog {
50
-    echo ''
50
+	FULLBLOG_DOMAIN_NAME='blog'
51
+	if grep -q "Blog domain" $COMPLETION_FILE; then
52
+		FULLBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Blog domain" | awk -F ':' '{print $2}')
53
+	fi
54
+
55
+	source_directory=/var/www/${FULLBLOG_DOMAIN_NAME}/htdocs
56
+	if [ -d $source_directory ]; then
57
+		dest_directory=blog
58
+		echo $"Backing up $source_directory to $dest_directory"
59
+
60
+		function_check suspend_site
61
+		suspend_site ${FULLBLOG_DOMAIN_NAME}
62
+
63
+		function_check backup_directory_to_usb
64
+		backup_directory_to_usb $source_directory $dest_directory
65
+
66
+		function_check restart_site
67
+		restart_site
68
+
69
+		echo $"Backup to $dest_directory complete"
70
+	fi
51 71
 }
52 72
 
53 73
 function backup_remote_blog {
54
-    echo ''
74
+	echo ''
55 75
 }
56 76
 
57 77
 function remove_blog {

+ 9
- 22
src/freedombone-backup-local Dosyayı Görüntüle

@@ -31,11 +31,18 @@
31 31
 PROJECT_NAME='freedombone'
32 32
 COMPLETION_FILE=$HOME/${PROJECT_NAME}-completed.txt
33 33
 BACKUP_EXTRA_DIRECTORIES=/root/backup-extra-dirs.csv
34
-ENABLE_VERIFICATION="no"
34
+ENABLE_BACKUP_VERIFICATION="no"
35 35
 
36 36
 export TEXTDOMAIN=${PROJECT_NAME}-backup-local
37 37
 export TEXTDOMAINDIR="/usr/share/locale"
38 38
 
39
+# include utils which allow function_check
40
+UTILS_FILES=/usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-*
41
+for f in $UTILS_FILES
42
+do
43
+  source $f
44
+done
45
+
39 46
 USB_DRIVE=/dev/sdb1
40 47
 USB_MOUNT=/mnt/usb
41 48
 
@@ -63,26 +70,6 @@ if [ -f /root/dbpass ]; then
63 70
 	DATABASE_PASSWORD=$(cat /root/dbpass)
64 71
 fi
65 72
 
66
-function suspend_site {
67
-	# suspends a given website
68
-	if [[ $ENABLE_VERIFICATION != "yes" ]]; then
69
-		return
70
-	fi
71
-	SUSPENDED_SITE="$1"
72
-	nginx_dissite $SUSPENDED_SITE
73
-	service nginx reload
74
-}
75
-
76
-function restart_site {
77
-	# restarts a given website
78
-	if [ ! $SUSPENDED_SITE ]; then
79
-		return
80
-	fi
81
-	nginx_ensite $SUSPENDED_SITE
82
-	service nginx reload
83
-	SUSPENDED_SITE=
84
-}
85
-
86 73
 function update_domains {
87 74
 	RSS_READER_DOMAIN_NAME='ttrss'
88 75
 	if grep -q "RSS reader domain" $COMPLETION_FILE; then
@@ -214,7 +201,7 @@ function backup_directory_to_usb {
214 201
 		fi
215 202
 		obnam force-lock -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID ${1}
216 203
 		obnam backup -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID ${1}
217
-		if [[ $ENABLE_VERIFICATION == "yes" ]]; then
204
+		if [[ $ENABLE_BACKUP_VERIFICATION == "yes" ]]; then
218 205
 			obnam verify -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID ${1}
219 206
 			if [ ! "$?" = "0" ]; then
220 207
 				umount $USB_MOUNT

+ 20
- 0
src/freedombone-utils-web Dosyayı Görüntüle

@@ -53,6 +53,9 @@ MAX_PHP_MEMORY=64
53 53
 # logging level for Nginx
54 54
 WEBSERVER_LOG_LEVEL='warn'
55 55
 
56
+# whether a given site is being suspended during backup
57
+SUSPENDED_SITE=
58
+
56 59
 # test a domain name to see if it's valid
57 60
 function validate_domain_name {
58 61
 	# count the number of dots in the domain name
@@ -548,4 +551,21 @@ function install_command_line_browser {
548 551
 	echo 'install_command_line_browser' >> $COMPLETION_FILE
549 552
 }
550 553
 
554
+function suspend_site {
555
+	# suspends a given website
556
+	SUSPENDED_SITE="$1"
557
+	nginx_dissite $SUSPENDED_SITE
558
+	service nginx reload
559
+}
560
+
561
+function restart_site {
562
+	# restarts a given website
563
+	if [ ! $SUSPENDED_SITE ]; then
564
+		return
565
+	fi
566
+	nginx_ensite $SUSPENDED_SITE
567
+	service nginx reload
568
+	SUSPENDED_SITE=
569
+}
570
+
551 571
 # NOTE: deliberately no exit 0