feat: add backup size metadata to response

This commit add backup size to response object using bash script.

This will also remove minio package as it changed to bash script
instead.
This commit is contained in:
Methapon2001 2024-07-16 13:34:15 +07:00
parent c963c040ef
commit 4fde3a7988
4 changed files with 57 additions and 233 deletions

View file

@ -884,3 +884,25 @@ mc rm "s3backup/${s3_backup_bucket}/${backup_name}.sql.gz" &
mc rb "s3backup/${backup_name}" --force &
wait
```
````bash
# shellcheck shell=bash
# List Backup
s3_backup_endpoint="$1"
s3_backup_access="$2"
s3_backup_secret="$3"
s3_backup_bucket="$4"
if [[ -z $(which mc) ]]; then
curl https://dl.min.io/client/mc/release/linux-amd64/mc -o /usr/local/bin/mc
chmod +x /usr/local/bin/mc
fi
mc alias set s3backup "$s3_backup_endpoint" "$s3_backup_access" "$s3_backup_secret"
list_database=$(mc ls --json "s3backup/${s3_backup_bucket}" | sed '1s/^/[/;$!s/$/,/;$s/$/]/')
list_bucket=$(mc du -depth 2 --json "s3backup" | sed '1s/^/[/;$!s/$/,/;$s/$/]/')
printf '{"bucket": %s, "database": %s}' "$list_bucket" "$list_database" | jq -c```
````