Bob Mottram 9 gadus atpakaļ
vecāks
revīzija
56fff9a6cd
1 mainītis faili ar 18 papildinājumiem un 15 dzēšanām
  1. 18
    15
      src/freedombone-backup-remote

+ 18
- 15
src/freedombone-backup-remote Parādīt failu

37
 export TEXTDOMAIN=${PROJECT_NAME}-backup-remote
37
 export TEXTDOMAIN=${PROJECT_NAME}-backup-remote
38
 export TEXTDOMAINDIR="/usr/share/locale"
38
 export TEXTDOMAINDIR="/usr/share/locale"
39
 
39
 
40
+# utilities needed for backup commands
40
 UTILS_FILES=/usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-*
41
 UTILS_FILES=/usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-*
41
 for f in $UTILS_FILES
42
 for f in $UTILS_FILES
42
 do
43
 do
102
 
103
 
103
 function backup_configuration {
104
 function backup_configuration {
104
 	echo $"Backing up ${PROJECT_NAME} configuration files"
105
 	echo $"Backing up ${PROJECT_NAME} configuration files"
105
-	if [ ! -d /root/tempbackupconfig ]; then
106
-		mkdir -p /root/tempbackupconfig
106
+	temp_backup_dir=/root/tempbackupconfig
107
+	if [ ! -d $temp_backup_dir ]; then
108
+		mkdir -p $temp_backup_dir
107
 	fi
109
 	fi
108
-	cp -f $CONFIG_FILE /root/tempbackupconfig
109
-	cp -f $COMPLETION_FILE /root/tempbackupconfig
110
+	cp -f $CONFIG_FILE $temp_backup_dir
111
+	cp -f $COMPLETION_FILE $temp_backup_dir
110
 	if [ -f $BACKUP_EXTRA_DIRECTORIES ]; then
112
 	if [ -f $BACKUP_EXTRA_DIRECTORIES ]; then
111
-		cp -f $BACKUP_EXTRA_DIRECTORIES /root/tempbackupconfig
113
+		cp -f $BACKUP_EXTRA_DIRECTORIES $temp_backup_dir
112
 	fi
114
 	fi
113
 	# nginx password hashes
115
 	# nginx password hashes
114
 	if [ -f /etc/nginx/.htpasswd ]; then
116
 	if [ -f /etc/nginx/.htpasswd ]; then
115
-		cp -f /etc/nginx/.htpasswd /root/tempbackupconfig/htpasswd
117
+		cp -f /etc/nginx/.htpasswd $temp_backup_dir/htpasswd
116
 	fi
118
 	fi
117
-	backup_directory_to_friend /root/tempbackupconfig config
119
+	backup_directory_to_friend $temp_backup_dir config
118
 }
120
 }
119
 
121
 
120
 function backup_users {
122
 function backup_users {
278
 
280
 
279
 function backup_mariadb {
281
 function backup_mariadb {
280
 	if [ ${#DATABASE_PASSWORD} -gt 1 ]; then
282
 	if [ ${#DATABASE_PASSWORD} -gt 1 ]; then
281
-		if [ ! -d /root/tempmariadb ]; then
282
-			mkdir /root/tempmariadb
283
+		temp_backup_dir=/root/tempmariadb
284
+		if [ ! -d $temp_backup_dir ]; then
285
+			mkdir $temp_backup_dir
283
 		fi
286
 		fi
284
-		mysqldump --password=$DATABASE_PASSWORD mysql user > /root/tempmariadb/mysql.sql
285
-		if [ ! -s /root/tempmariadb/mysql.sql ]; then
287
+		mysqldump --password=$DATABASE_PASSWORD mysql user > $temp_backup_dir/mysql.sql
288
+		if [ ! -s $temp_backup_dir/mysql.sql ]; then
286
 			echo $"Unable to backup MariaDB settings"
289
 			echo $"Unable to backup MariaDB settings"
287
-			rm -rf /root/tempmariadb
290
+			rm -rf $temp_backup_dir
288
 			# Send a warning email
291
 			# Send a warning email
289
 			echo $"Unable to export database settings" | mail -s "${PROJECT_NAME} backup to friends" $ADMIN_EMAIL_ADDRESS
292
 			echo $"Unable to export database settings" | mail -s "${PROJECT_NAME} backup to friends" $ADMIN_EMAIL_ADDRESS
290
 			exit 653
293
 			exit 653
291
 		fi
294
 		fi
292
-		echo "$DATABASE_PASSWORD" > /root/tempmariadb/db
293
-		chmod 400 /root/tempmariadb/db
294
-		backup_directory_to_friend /root/tempmariadb mariadb
295
+		echo "$DATABASE_PASSWORD" > $temp_backup_dir/db
296
+		chmod 400 $temp_backup_dir/db
297
+		backup_directory_to_friend $temp_backup_dir mariadb
295
 	fi
298
 	fi
296
 }
299
 }
297
 
300