Skip to content

Commit f332636

Browse files
authored
Delete backup when local set to no (hestiacp#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
1 parent 9c2f1ee commit f332636

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
# Bats seems to break Prettier
1818
*.bats
1919

20+
# Exclude bats submodules if present
21+
/test/test_helper/*
22+
2023
# Web templates (for now)
2124
web/templates/
2225

bin/v-add-backup-host

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,10 @@ if [ "$type" = 'rclone' ]; then
291291
echo "test" > /tmp/hestia-backup.txt
292292
# Try to upload a single file
293293
if [ -z "$path" ]; then
294-
rclone copy /tmp/hestia-backup $host:/hestia-backup.txt
294+
rclone copy /tmp/hestia-backup.txt $host:/hestia-backup.txt
295295
rclone delete $host:/hestia-backup.txt
296296
else
297-
rclone copy /tmp/hestia-backup $host:$path/hestia-backup.txt
297+
rclone copy /tmp/hestia-backup.txt $host:$path/hestia-backup.txt
298298
rclone delete $host:$path/hestia-backup.txt
299299
fi
300300
else

func/backup.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -522,13 +522,14 @@ b2_backup() {
522522
backup_list=$(b2 ls --long $BUCKET $user | cut -f 1 -d ' ' 2> /dev/null)
523523
backups_count=$(echo "$backup_list" | wc -l)
524524
if [ "$backups_count" -ge "$BACKUPS" ]; then
525-
backups_rm_number=$((backups_count - BACKUPS))
525+
backups_rm_number=$(($backups_count - $BACKUPS))
526526
for backup in $(echo "$backup_list" | head -n $backups_rm_number); do
527527
backup_file_name=$(b2 get-file-info $backup | grep fileName | cut -f 4 -d '"' 2> /dev/null)
528528
echo -e "$(date "+%F %T") Rotated b2 backup: $backup_file_name"
529529
b2 delete-file-version $backup > /dev/null 2>&1
530530
done
531531
fi
532+
532533
}
533534

534535
b2_download() {
@@ -589,14 +590,18 @@ rclone_backup() {
589590

590591
backup_list=$(rclone lsf $HOST:$BPATH | cut -d' ' -f1 | grep "^$user\.")
591592
backups_count=$(echo "$backup_list" | wc -l)
592-
backups_rm_number=$((backups_count - BACKUPS))
593+
backups_rm_number=$(($backups_count - $BACKUPS))
593594
if [ "$backups_count" -ge "$BACKUPS" ]; then
594595
for backup in $(echo "$backup_list" | head -n $backups_rm_number); do
595596
echo "Delete file: $backup"
596597
rclone deletefile $HOST:$BPATH/$backup
597598
done
598599
fi
599600
fi
601+
if [ "$localbackup" != 'yes' ]; then
602+
rm -f $user.$backup_new_date.tar
603+
fi
604+
600605
}
601606

602607
rclone_delete() {
@@ -610,6 +615,7 @@ rclone_delete() {
610615
}
611616

612617
rclone_download() {
618+
613619
# Defining rclone b2 settings
614620
source_conf "$HESTIA/conf/rclone.backup.conf"
615621
cd $BACKUP

0 commit comments

Comments
 (0)