The disk space was running low, so I checked the folders taking up space on my VPS server. I noticed that there are 32 folders inside the /root/hst_backups directory, and they are occupying space. “Last change” is between 2021 and 2022 years.
I don’t know their purpose. Would deleting them cause any issues?
Those folders are Hestia’s conf backups made before the Hestia’s upgrade to a new version. If you don’t need those backups, you can remove them, no problem but those backups should take up little space.
This is a scheduled task that I use to automatically delete backups. Perhaps we can consider adding it to future updates
#!/bin/bash
#The directory where the backup file is located
backup_dir="backup"
#Switch to backup directory
cd "$backup_dir"
#Search for all backup files and categorize them by user
shopt -s nullglob
for user_tar in *.tar; do
#Get the user name (the part before the first dot in the file name)
user_name="${user_tar%%.*}"
#If there are multiple files, find the latest file (by modification time)
latest_backup=$(ls -t "${user_name}."*.tar | head -n 1)
#If there are old backup files, delete them
if [[ -n "$latest_backup" ]]; then
Echo "Keep the latest backup: $latest_mackup"
#Use ls to search for all backup files except for the latest backup
for old_backup in ${user_name}.*.tar; do
if [[ "$old_backup" != "$latest_backup" ]]; then
Echo "Delete old backup: $old_mackup"
rm -f "$old_backup"
fi
done
fi
done
#Turn off the null globe option
shopt -u nullglob
Echo "Cleanup completed. "
Starting to clean up backup files
Keep the latest backup: admin. 2022-11-17_05-10-02.tar
Delete old backup:
admin.2024-11-16_05-10-03.tar
Keep the latest backup: admin. 2022-11-17_05-10-02.tar
Delete old backup:
Keep the latest backup: www.2024-11-17_05-10-11.tar
Delete old backup:
www.2024-11-16_05-10-17.tar
Keep the latest backup: www.2024-11-17_05-10-11.tar
Delete old backup:
Two old backup files were deleted in total.
Cleaning completed.