Skip to content

Commit e71a161

Browse files
authored
Update v-backup-user
I noticed that I always seemed to have 1 less backup than I was supposed to in my VestaCP. This fix resolves the issue for me. Problem outlined: - My VestaCP package says that I'm supposed to be allowed 3 backups. - The backups tab of the GUI showed that I had 3 backups. - I was never able to access the oldest backup (Almost like it wasn't actually there). - I checked the backup folder using SSH and I found that I only ever have the latest 2 backups available. - It was clear that a script was deleting the 3rd backup prematurely.
1 parent 4e769aa commit e71a161

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
@@ -483,7 +483,6 @@ local_backup(){
483483
backups_count=$(echo "$backup_list" |wc -l)
484484
if [ "$BACKUPS" -le "$backups_count" ]; then
485485
backups_rm_number=$((backups_count - BACKUPS))
486-
(( ++backups_rm_number))
487486

488487
# Removing old backup
489488
for backup in $(echo "$backup_list" |head -n $backups_rm_number); do
@@ -599,7 +598,7 @@ ftp_backup() {
599598
fi
600599
backups_count=$(echo "$backup_list" |wc -l)
601600
if [ "$backups_count" -ge "$BACKUPS" ]; then
602-
backups_rm_number=$((backups_count - BACKUPS + 1))
601+
backups_rm_number=$((backups_count - BACKUPS))
603602
for backup in $(echo "$backup_list" |head -n $backups_rm_number); do
604603
backup_date=$(echo $backup |sed -e "s/$user.//" -e "s/.tar$//")
605604
echo -e "$(date "+%F %T") Rotated ftp backup: $backup_date" |\
@@ -754,7 +753,7 @@ sftp_backup() {
754753
fi
755754
backups_count=$(echo "$backup_list" |wc -l)
756755
if [ "$backups_count" -ge "$BACKUPS" ]; then
757-
backups_rm_number=$((backups_count - BACKUPS + 1))
756+
backups_rm_number=$((backups_count - BACKUPS))
758757
for backup in $(echo "$backup_list" |head -n $backups_rm_number); do
759758
backup_date=$(echo $backup |sed -e "s/$user.//" -e "s/.tar.*$//")
760759
echo -e "$(date "+%F %T") Rotated sftp backup: $backup_date" |\
@@ -803,7 +802,7 @@ google_backup() {
803802
backup_list=$(${gsutil} ls gs://$BUCKET/$BPATH/$user.* 2>/dev/null)
804803
backups_count=$(echo "$backup_list" |wc -l)
805804
if [ "$backups_count" -ge "$BACKUPS" ]; then
806-
backups_rm_number=$((backups_count - BACKUPS + 1))
805+
backups_rm_number=$((backups_count - BACKUPS))
807806
for backup in $(echo "$backup_list" |head -n $backups_rm_number); do
808807
echo -e "$(date "+%F %T") Roated gcp backup: $backup"
809808
$gsutil rm $backup > /dev/null 2>&1

0 commit comments

Comments
 (0)