HestiaCP Backup to AWS S3

Hi HestiaCP family,

I have a basic bash script to upload local backup files to the AWS S3 Service. I had to inject this code into the ‘usr/local/hestia/bin/v-backup-user’ file. I know this is not an appropriate way to implement such custom code. Most probably, if the Hestia has any updates, the custom codes will revert to the original. My point is; how can implement such a custom script as the continuos of the ‘v-backup-user’ process.

Basically, the script is like that.


# Delete 4th file from AWS S3
COUNTFILES=`aws s3 ls $BUCKET --recursive | wc -l | xargs`;
if [[ $COUNTFILES -gt 3 ]]
  KEY=`aws s3 ls $BUCKET --recursive | sort | tail -n 1 | awk '{print $4}'`; 
  aws s3api delete-object --bucket $BUCKET --key $KEY

# Send file to AWS
echo "$(date "+%F %T") AWS S3 Details: " |tee -a $BACKUP/$user.log
aws s3api put-object --bucket $BUCKET --key $user.$backup_new_date.tar --body $BACKUP/$user.$backup_new_date.tar |tee -a $BACKUP/$user.log

Anyway, a couple of days later, I found a solution to help other people who may have the same problem. That’s why I felt compelled to explain how I did it.

I decided to implement it with folder watching services such as Watchman or inotify-tools. Basically, I’m watching the root/backup folder, and if there are any changes, I transfer the latest backup file to the AWS S3 services. In this way, I do not intervene in the original HestiaCP commands.

1 Like

Other option would be using rclone