From 8d9e65f2abc76dfcb04677c893b7c877fccfd12f Mon Sep 17 00:00:00 2001 From: Jens Stark Date: Sun, 22 Sep 2024 23:40:59 +0200 Subject: [PATCH 1/2] victoriametrics: use conf.d folder in backup scripts --- packages/victoriametrics/vmbackup-cleanup-cron | 9 +++++++-- packages/victoriametrics/vmbackup-cron | 8 ++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/victoriametrics/vmbackup-cleanup-cron b/packages/victoriametrics/vmbackup-cleanup-cron index ca325c22e..1c01d4f9f 100644 --- a/packages/victoriametrics/vmbackup-cleanup-cron +++ b/packages/victoriametrics/vmbackup-cleanup-cron @@ -2,13 +2,18 @@ LOG_DIR=${OMD_ROOT}/var/victoriametrics DATA_PATH=${OMD_ROOT}/var/victoriametrics/data +CONF_DIR=$OMD_ROOT/etc/victoriametrics/conf.d mkdir -p $LOG_DIR ( -. ${OMD_ROOT}/etc/victoriametrics/victoriametrics.conf -if [ $? != 0 ] ; then +for CFG in ${CONF_DIR}/*.conf; do + . ${CFG} +done +. etc/victoriametrics/backup.conf + +if [ -z "$vm_loggerLevel" ] ; then echo "source of config failed" exit 8 fi diff --git a/packages/victoriametrics/vmbackup-cron b/packages/victoriametrics/vmbackup-cron index f216d4335..69f103c6a 100644 --- a/packages/victoriametrics/vmbackup-cron +++ b/packages/victoriametrics/vmbackup-cron @@ -2,14 +2,18 @@ LOG_DIR=${OMD_ROOT}/var/victoriametrics DATA_PATH=${OMD_ROOT}/var/victoriametrics/data +CONF_DIR=$OMD_ROOT/etc/victoriametrics/conf.d mkdir -p $LOG_DIR ( -. ${OMD_ROOT}/etc/victoriametrics/victoriametrics.conf +for CFG in ${CONF_DIR}/*.conf; do + . ${CFG} +done +. etc/victoriametrics/backup.conf -if [ $? != 0 ] ; then +if [ -z "$vm_loggerLevel" ] ; then echo "source of config failed" exit 8 fi From d5401b190ac62968c0b298f3ff023b916a1f8a84 Mon Sep 17 00:00:00 2001 From: Jens Stark Date: Sun, 22 Sep 2024 23:43:06 +0200 Subject: [PATCH 2/2] victoriametrics: replaced jsonpath.py whit grep and tr --- packages/victoriametrics/vmbackup-cleanup-cron | 4 ++-- packages/victoriametrics/vmbackup-cron | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/victoriametrics/vmbackup-cleanup-cron b/packages/victoriametrics/vmbackup-cleanup-cron index 1c01d4f9f..a40e49f9f 100644 --- a/packages/victoriametrics/vmbackup-cleanup-cron +++ b/packages/victoriametrics/vmbackup-cleanup-cron @@ -54,8 +54,8 @@ fi echo ">> retention at $( date +%Y-%m-%d-%H) " RC=0 -LL=$(echo -n $SNAPSHOT_OUT | jsonpath.py '$.snapshots[*]') -for SNAPSHOT_NAME in $(echo -n $SNAPSHOT_OUT | jsonpath.py '$.snapshots[*]') + +for SNAPSHOT_NAME in $(echo -n $SNAPSHOT_OUT | grep -oP '"snapshots": *\[\K[^]]+' | tr -d ' "' | tr ',' ' ') do echo "snapshots: ${SNAPSHOT_NAME}" #du -ch -d1 $storageDataPath/snapshots/${SNAPSHOT_NAME} diff --git a/packages/victoriametrics/vmbackup-cron b/packages/victoriametrics/vmbackup-cron index 69f103c6a..f49ec0a31 100644 --- a/packages/victoriametrics/vmbackup-cron +++ b/packages/victoriametrics/vmbackup-cron @@ -74,7 +74,7 @@ fi echo $SNAPSHOT_OUT -SNAPSHOT_NAME=$(echo -n $SNAPSHOT_OUT | jsonpath.py '$.snapshot') +SNAPSHOT_NAME=$(echo -n $SNAPSHOT_OUT | grep -oP '"snapshot": *"\K[^"]+') if [ "${SNAPSHOT_NAME}" = "" ] ; then echo "snapshot failed"