ngosang / restic-exporter

Prometheus exporter for the Restic backup system
MIT License
79 stars 17 forks source link

S3 Support? #2

Closed RogerSik closed 1 year ago

RogerSik commented 1 year ago

Is s3 supported? When setting RESTIC_REPO_URL with s3 as the http example it fails


2023-01-23 07:36:46 INFO     Starting Restic Prometheus Exporter ...
2023-01-23 07:36:46 INFO     It could take a while if the repository is remote.
Fatal: unable to open config file: Stat: The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256.
Is there a repository at the following location?
s3:access_key:secret_key@fqdn/bucket-name/
2023-01-23 07:36:57 ERROR    Unable to collect metrics from Restic. Error: Error executing restic snapshot command. Exit code: 1
Traceback (most recent call last):
  File "/restic-exporter.py", line 226, in <module>
    prometheus_client.core.REGISTRY.register(collector)
  File "/usr/local/lib/python3.11/site-packages/prometheus_client/registry.py", line 40, in register
    names = self._get_names(collector)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/prometheus_client/registry.py", line 80, in _get_names
    for metric in desc_func():
  File "/restic-exporter.py", line 66, in collect
    check_success.add_metric([], self.metrics["check_success"])
                                 ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
KeyError: 'check_success'
``
ngosang commented 1 year ago

I never tested it. Just local and rest.

RESTIC_REPO_URL: Restic repository URL. It could be a local repository (eg: /data) or a remote repository (eg: rest:http://user:password@127.0.0.1:8000/).

I don't have an s3 account. If I open a PR could yo test it? Do you need a Docker image or just source code is enough?

RogerSik commented 1 year ago

Yes I could. I could provide you test credentials and test instance.

ngosang commented 1 year ago

I tried Minio (S3 compatible) and it's working fine. You have to add more Environment variables. The same as in Restic => https://restic.readthedocs.io/en/latest/030_preparing_a_new_repo.html#amazon-s3

      - RESTIC_REPO_URL=s3:http://10.0.2.15:9002/restic
      - RESTIC_REPO_PASSWORD=rS45Tgt2eJ
      - AWS_ACCESS_KEY_ID=oR5BtezJSXP
      - AWS_SECRET_ACCESS_KEY=dnNtGQIfxDWdmFljUrHDHEYjH
RogerSik commented 1 year ago

Yes you are right this works fine @ngosang. Many thanks and sorry, i was wrong in the thinking and tried to include the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY into the RESTIC_REPO_URL like the http example.