Przeglądaj źródła

Delete backup when local set to no (#3076)

* Delete backup when local set to no

- Fix deleting backups when more then 1 backup should be kept

Use /tmp/hestia-backup.txt instead /tmp/hestia-backup


Fix typo

* Run Prettier

- Add /test/test_helper/* to ignore list if submodules are present!

* Fix permissions
Jaap Marcus 3 lat temu
rodzic
commit
f33263650b
3 zmienionych plików z 13 dodań i 4 usunięć
  1. 3 0
      .prettierignore
  2. 2 2
      bin/v-add-backup-host
  3. 8 2
      func/backup.sh

+ 3 - 0
.prettierignore

@@ -17,6 +17,9 @@
 # Bats seems to break Prettier
 *.bats
 
+# Exclude bats submodules if present
+/test/test_helper/*
+
 # Web templates (for now)
 web/templates/
 

+ 2 - 2
bin/v-add-backup-host

@@ -291,10 +291,10 @@ if [ "$type" = 'rclone' ]; then
 		echo "test" > /tmp/hestia-backup.txt
 		# Try to upload a single file
 		if [ -z "$path" ]; then
-			rclone copy /tmp/hestia-backup $host:/hestia-backup.txt
+			rclone copy /tmp/hestia-backup.txt $host:/hestia-backup.txt
 			rclone delete $host:/hestia-backup.txt
 		else
-			rclone copy /tmp/hestia-backup $host:$path/hestia-backup.txt
+			rclone copy /tmp/hestia-backup.txt $host:$path/hestia-backup.txt
 			rclone delete $host:$path/hestia-backup.txt
 		fi
 	else

+ 8 - 2
func/backup.sh

@@ -522,13 +522,14 @@ b2_backup() {
 	backup_list=$(b2 ls --long $BUCKET $user | cut -f 1 -d ' ' 2> /dev/null)
 	backups_count=$(echo "$backup_list" | wc -l)
 	if [ "$backups_count" -ge "$BACKUPS" ]; then
-		backups_rm_number=$((backups_count - BACKUPS))
+		backups_rm_number=$(($backups_count - $BACKUPS))
 		for backup in $(echo "$backup_list" | head -n $backups_rm_number); do
 			backup_file_name=$(b2 get-file-info $backup | grep fileName | cut -f 4 -d '"' 2> /dev/null)
 			echo -e "$(date "+%F %T") Rotated b2 backup: $backup_file_name"
 			b2 delete-file-version $backup > /dev/null 2>&1
 		done
 	fi
+
 }
 
 b2_download() {
@@ -589,7 +590,7 @@ rclone_backup() {
 
 		backup_list=$(rclone lsf $HOST:$BPATH | cut -d' ' -f1 | grep "^$user\.")
 		backups_count=$(echo "$backup_list" | wc -l)
-		backups_rm_number=$((backups_count - BACKUPS))
+		backups_rm_number=$(($backups_count - $BACKUPS))
 		if [ "$backups_count" -ge "$BACKUPS" ]; then
 			for backup in $(echo "$backup_list" | head -n $backups_rm_number); do
 				echo "Delete file: $backup"
@@ -597,6 +598,10 @@ rclone_backup() {
 			done
 		fi
 	fi
+	if [ "$localbackup" != 'yes' ]; then
+		rm -f $user.$backup_new_date.tar
+	fi
+
 }
 
 rclone_delete() {
@@ -610,6 +615,7 @@ rclone_delete() {
 }
 
 rclone_download() {
+
 	# Defining rclone b2 settings
 	source_conf "$HESTIA/conf/rclone.backup.conf"
 	cd $BACKUP