routeros-trigger-a-backup/trigger-a-backup.sh

30 lines
610 B
Bash
Raw Normal View History

2024-03-19 02:20:12 +02:00
#!/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