Skip to content

Commit d5f78d5

Browse files
Merge pull request hestiacp#1237 from cmstew/cmstew-v-user-backup-patch
Update v-backup-user / Fix from @cmstew
2 parents 472a0f4 + e71a161 commit d5f78d5

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

bin/v-backup-user

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,6 @@ local_backup(){
484484
backups_count=$(echo "$backup_list" |wc -l)
485485
if [ "$BACKUPS" -le "$backups_count" ]; then
486486
backups_rm_number=$((backups_count - BACKUPS))
487-
(( ++backups_rm_number))
488487

489488
# Removing old backup
490489
for backup in $(echo "$backup_list" |head -n $backups_rm_number); do
@@ -600,7 +599,7 @@ ftp_backup() {
600599
fi
601600
backups_count=$(echo "$backup_list" |wc -l)
602601
if [ "$backups_count" -ge "$BACKUPS" ]; then
603-
backups_rm_number=$((backups_count - BACKUPS + 1))
602+
backups_rm_number=$((backups_count - BACKUPS))
604603
for backup in $(echo "$backup_list" |head -n $backups_rm_number); do
605604
backup_date=$(echo $backup |sed -e "s/$user.//" -e "s/.tar$//")
606605
echo -e "$(date "+%F %T") Rotated ftp backup: $backup_date" |\
@@ -755,7 +754,7 @@ sftp_backup() {
755754
fi
756755
backups_count=$(echo "$backup_list" |wc -l)
757756
if [ "$backups_count" -ge "$BACKUPS" ]; then
758-
backups_rm_number=$((backups_count - BACKUPS + 1))
757+
backups_rm_number=$((backups_count - BACKUPS))
759758
for backup in $(echo "$backup_list" |head -n $backups_rm_number); do
760759
backup_date=$(echo $backup |sed -e "s/$user.//" -e "s/.tar.*$//")
761760
echo -e "$(date "+%F %T") Rotated sftp backup: $backup_date" |\
@@ -804,7 +803,7 @@ google_backup() {
804803
backup_list=$(${gsutil} ls gs://$BUCKET/$BPATH/$user.* 2>/dev/null)
805804
backups_count=$(echo "$backup_list" |wc -l)
806805
if [ "$backups_count" -ge "$BACKUPS" ]; then
807-
backups_rm_number=$((backups_count - BACKUPS + 1))
806+
backups_rm_number=$((backups_count - BACKUPS))
808807
for backup in $(echo "$backup_list" |head -n $backups_rm_number); do
809808
echo -e "$(date "+%F %T") Roated gcp backup: $backup"
810809
$gsutil rm $backup > /dev/null 2>&1

0 commit comments

Comments
 (0)