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.
BUCKET="s3bucketname"
# Delete 4th file from AWS S3
COUNTFILES=`aws s3 ls $BUCKET --recursive | wc -l | xargs`;
if [[ $COUNTFILES -gt 3 ]]
then
KEY=`aws s3 ls $BUCKET --recursive | sort | tail -n 1 | awk '{print $4}'`;
aws s3api delete-object --bucket $BUCKET --key $KEY
fi
# 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