Make backup directory configurable

This commit is contained in:
Timothée Floure 2020-11-20 07:53:04 +01:00
parent 3d719f07d6
commit 6cba6cc667

View file

@ -4,12 +4,13 @@ from prometheus_client import start_http_server, Gauge
from time import sleep, mktime
from dateutil import parser
import sys
import os
import json
import subprocess
HTTP_PORT = 9401
BACKUP_DIRECTORY = '/tmp/backup'
BACKUP_DIRECTORY = '/srv/backup'
INTERVAL = 30 * 60 # seconds
total_chunks = Gauge('borg_repository_total_chunks', 'Number of chunks', ['name'])
@ -22,6 +23,13 @@ last_modified = Gauge('borg_repository_last_modified', 'Last modified UNIX
if __name__ == '__main__':
if len(sys.argv) == 2:
BACKUP_DIRECTORY = sys.argv[1]
elif len(sys.argv) > 2:
sys.exit("Invalid number of arguments. Usage: ./prometheus-borgbackup-exporter [backup-directory]")
print("Backup directory is: {}".format(BACKUP_DIRECTORY))
# Serve metrics over HTTP.
print("Starting prometheus-orgbackup-exporter on port",
"{}...".format(HTTP_PORT), end='')