From 77de9c7b6ed23b78df4c105841cff8526588c0a1 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 19 Mar 2024 02:20:12 +0200 Subject: [PATCH] 1 --- trigger-a-backup.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 trigger-a-backup.sh diff --git a/trigger-a-backup.sh b/trigger-a-backup.sh new file mode 100755 index 0000000..78d491b --- /dev/null +++ b/trigger-a-backup.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +DEBUG="0" + +ROUTEROS_HOST="$1" +USERNAME="$2" +PASSWORD="$3" + +BACKUP_FILENAME="$4" + +if [ -z "${BACKUP_FILENAME}" ] +then + echo "Missing backup filename" >&2 + exit 1 +fi + +if [ ! -z "${BACKUP_FILENAME}" ] +then + + if [ "${DEBUG}" -gt "0" ];then + echo -n "DEBUG LEVEL 1: Working on CIDR: " >&2 + echo "${i}" >&2 + fi + + COMMAND_RES=$(curl -v -k -u ${USERNAME}:${PASSWORD} -X POST "https://${ROUTEROS_HOST}/rest/system/backup/save" \ + -H "content-type: application/json" \ + --data "{\"dont-encrypt\": \"yes\", \"name\": \"${BACKUP_FILENAME}\"}") + echo "${COMMAN_RES}" +fi