Skip to content

Commit 5747cfa

Browse files
wojsmoljaapmarcus
andauthored
Add b2 support to v-delete-user-backup (hestiacp#2253)
* Add b2 support to v-delete-user-backup * Adress mistake made in https://github.com/hestiacp/hestiacp/blame/e2d7eb9da2af4372d8f11b07ad3a56cf3da970bb/func/backup.sh#L437 + https://github.com/hestiacp/hestiacp/blame/e2d7eb9da2af4372d8f11b07ad3a56cf3da970bb/func/backup.sh#L442 Adjusted v-delete-user-backup accordingly Co-authored-by: Jaap Marcus <9754650+jaapmarcus@users.noreply.github.com>
1 parent 622fd8c commit 5747cfa

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

bin/v-delete-user-backup

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,14 @@ fi
5757
if [[ "$TYPE" =~ "ftp" ]] && [ "$deleted" == "0" ]; then
5858
ftp_delete "$backup"
5959
fi
60+
if [[ "$TYPE" =~ "b2" ]]; then
61+
b2_delete "$user" "$backup"
62+
fi
6063
if [[ "$TYPE" =~ "local" ]]; then
6164
rm -f "$backup_folder/$2"
6265
fi
6366

67+
6468
# Deleting backup
6569
sed -i "/BACKUP='$2' /d" "$USER_DATA/backup.conf"
6670

func/backup.sh

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,12 +434,12 @@ b2_backup() {
434434
echo -e "$(date "+%F %T") Upload to B2: $user/$user.$backup_new_date.tar"
435435
if [ "$localbackup" = 'yes' ]; then
436436
cd $BACKUP
437-
b2 upload-file $BUCKET $user.$backup_new_date.tar $user/$user.tar
437+
b2 upload-file $BUCKET $user.$backup_new_date.tar $user/$user.$backup_new_date.tar > /dev/null 2>&1
438438
else
439439
cd $tmpdir
440440
tar -cf $BACKUP/$user.$backup_new_date.tar .
441441
cd $BACKUP/
442-
b2 upload-file $BUCKET $user.$backup_new_date.tar $user/$user.tar
442+
b2 upload-file $BUCKET $user.$backup_new_date.tar $user/$user.$backup_new_date.tar > /dev/null 2>&1
443443
rc=$?
444444
rm -f $user.$backup_new_date.tar
445445
if [ "$rc" -ne 0 ]; then
@@ -472,4 +472,15 @@ b2_download() {
472472
if [ "$?" -ne 0 ]; then
473473
check_result "$E_CONNECT" "b2 failed to download $user.$1"
474474
fi
475+
}
476+
477+
b2_delete(){
478+
# Defining backblaze b2 settings
479+
source_conf "$HESTIA/conf/b2.backup.conf"
480+
481+
# Recreate backblaze auth file ~/.b2_account_info (for situation when key was changed in b2.backup.conf)
482+
b2 clear-account > /dev/null 2>&1
483+
b2 authorize-account $B2_KEYID $B2_KEY > /dev/null 2>&1
484+
485+
b2 delete-file-version $1/$2 > /dev/null 2>&1
475486
}

0 commit comments

Comments
 (0)