aboutsummaryrefslogtreecommitdiff
path: root/docker/auto-backup/daemon.bash
diff options
context:
space:
mode:
Diffstat (limited to 'docker/auto-backup/daemon.bash')
-rwxr-xr-xdocker/auto-backup/daemon.bash30
1 files changed, 19 insertions, 11 deletions
diff --git a/docker/auto-backup/daemon.bash b/docker/auto-backup/daemon.bash
index 33708ee..6a39fa5 100755
--- a/docker/auto-backup/daemon.bash
+++ b/docker/auto-backup/daemon.bash
@@ -8,18 +8,23 @@ if [[ $EUID -ne 0 ]]; then
exit 1
fi
-# Check if CRUPEST_AUTO_BACKUP_BUCKET_NAME is defined.
-if [[ -z "$CRUPEST_AUTO_BACKUP_BUCKET_NAME" ]]; then
- echo "CRUPEST_AUTO_BACKUP_BUCKET_NAME is not defined or empty"
- exit 1
-fi
-
-rclone --version
+/coscli --version
# Check xz and tar
xz --version
tar --version
+bucket_yaml=$(/coscli config show | yq ".buckets[] | select(.alias == \"crupest-backup\")")
+
+# check bucket_yaml is not empty
+if [[ -z "$bucket_yaml" ]]; then
+ echo "Bucket crupest-backup not found. Please check your coscli config." 1>&2
+ exit 1
+fi
+
+bucket_name=$(echo "$bucket_yaml" | yq ".name")
+bucket_region=$(echo "$bucket_yaml" | yq ".region")
+
function backup {
# Output "Begin backup..." in yellow and restore default
echo -e "\e[0;103m\e[K\e[1mBegin backup..." "\e[0m"
@@ -33,12 +38,15 @@ function backup {
tar -cJf /tmp/data.tar.xz -C / data
# Output /tmp/data.tar.xz size
- du -h /tmp/data.tar.xz
+ du -h /tmp/data.tar.xz | cut -f1 | xargs echo "Size of data.tar.xz:"
+
+ destination="cos://crupest-backup/$current_time.tar.xz"
+ echo "Use coscli to upload data to $destination ..."
+ echo "Bucket name: $bucket_name"
+ echo "Bucket region: $bucket_region"
- destination="mycos:$CRUPEST_AUTO_BACKUP_BUCKET_NAME/$current_time.tar.xz"
- echo "Use rclone to upload data to $destination ..."
# upload to remote
- rclone -vv copyto /tmp/data.tar.xz "$destination"
+ /coscli cp /tmp/data.tar.xz "$destination"
echo "Remove tmp file..."
# remove tmp