Replaced RESTIC_REPO_URL, RESTIC_REPO_PASSWORD and RESTIC_REPO_PASSWORD_FILE environment variables
This commit is contained in:
parent
10dae8da3a
commit
4efcaba7c5
4 changed files with 51 additions and 30 deletions
28
README.md
28
README.md
|
@ -19,8 +19,8 @@ Requirements:
|
||||||
```bash
|
```bash
|
||||||
pip install -r /requirements.txt
|
pip install -r /requirements.txt
|
||||||
|
|
||||||
export RESTIC_REPO_URL=/data
|
export RESTIC_REPOSITORY=/data
|
||||||
export RESTIC_REPO_PASSWORD_FILE=/restic_password_file
|
export RESTIC_PASSWORD_FILE=/restic_password_file
|
||||||
python restic-exporter.py
|
python restic-exporter.py
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -59,9 +59,9 @@ services:
|
||||||
container_name: restic-exporter
|
container_name: restic-exporter
|
||||||
environment:
|
environment:
|
||||||
- TZ=Europe/Madrid
|
- TZ=Europe/Madrid
|
||||||
- RESTIC_REPO_URL=/data
|
- RESTIC_REPOSITORY=/data
|
||||||
- RESTIC_REPO_PASSWORD=<password_here>
|
- RESTIC_PASSWORD=<password_here>
|
||||||
# - RESTIC_REPO_PASSWORD_FILE=</file_with_password_here>
|
# - RESTIC_PASSWORD_FILE=</file_with_password_here>
|
||||||
- REFRESH_INTERVAL=1800 # 30 min
|
- REFRESH_INTERVAL=1800 # 30 min
|
||||||
volumes:
|
volumes:
|
||||||
- /host_path/restic/data:/data
|
- /host_path/restic/data:/data
|
||||||
|
@ -76,8 +76,8 @@ services:
|
||||||
docker run -d \
|
docker run -d \
|
||||||
--name=restic-exporter \
|
--name=restic-exporter \
|
||||||
-e TZ=Europe/Madrid \
|
-e TZ=Europe/Madrid \
|
||||||
-e RESTIC_REPO_URL=/data \
|
-e RESTIC_REPOSITORY=/data \
|
||||||
-e RESTIC_REPO_PASSWORD=<password_here> \
|
-e RESTIC_PASSWORD=<password_here> \
|
||||||
-e REFRESH_INTERVAL=1800 \
|
-e REFRESH_INTERVAL=1800 \
|
||||||
-p 8001:8001 \
|
-p 8001:8001 \
|
||||||
--restart unless-stopped \
|
--restart unless-stopped \
|
||||||
|
@ -91,17 +91,17 @@ Some of them need additional environment variables for the secrets.
|
||||||
|
|
||||||
All configuration is done with environment variables:
|
All configuration is done with environment variables:
|
||||||
|
|
||||||
- `RESTIC_REPO_URL`: Restic repository URL. All backends are supported. Examples:
|
- `RESTIC_REPOSITORY`: Restic repository URL. All backends are supported. Examples:
|
||||||
* Local repository: `/data`
|
* Local repository: `/data`
|
||||||
* REST Server: `rest:http://user:password@127.0.0.1:8000/`
|
* REST Server: `rest:http://user:password@127.0.0.1:8000/`
|
||||||
* Amazon S3: `s3:s3.amazonaws.com/bucket_name`
|
* Amazon S3: `s3:s3.amazonaws.com/bucket_name`
|
||||||
* Backblaze B2: `b2:bucketname:path/to/repo`
|
* Backblaze B2: `b2:bucketname:path/to/repo`
|
||||||
* Rclone (see notes below): `rclone:gd-backup:/restic`
|
* Rclone (see notes below): `rclone:gd-backup:/restic`
|
||||||
|
|
||||||
- `RESTIC_REPO_PASSWORD`: Restic repository password in plain text. This is only
|
- `RESTIC_PASSWORD`: Restic repository password in plain text. This is only
|
||||||
required if `RESTIC_REPO_PASSWORD_FILE` is not defined.
|
required if `RESTIC_PASSWORD_FILE` is not defined.
|
||||||
- `RESTIC_REPO_PASSWORD_FILE`: File with the Restic repository password in plain
|
- `RESTIC_PASSWORD_FILE`: File with the Restic repository password in plain
|
||||||
text. This is only required if `RESTIC_REPO_PASSWORD` is not defined. Remember
|
text. This is only required if `RESTIC_PASSWORD` is not defined. Remember
|
||||||
to mount the Docker volume with the file.
|
to mount the Docker volume with the file.
|
||||||
- `AWS_ACCESS_KEY_ID`: (Optional) Required for Amazon S3, Minio and Wasabi
|
- `AWS_ACCESS_KEY_ID`: (Optional) Required for Amazon S3, Minio and Wasabi
|
||||||
backends.
|
backends.
|
||||||
|
@ -138,8 +138,8 @@ services:
|
||||||
container_name: restic-exporter
|
container_name: restic-exporter
|
||||||
environment:
|
environment:
|
||||||
- TZ=Europe/Madrid
|
- TZ=Europe/Madrid
|
||||||
- RESTIC_REPO_URL=rclone:gd-backup:/restic
|
- RESTIC_REPOSITORY=rclone:gd-backup:/restic
|
||||||
- RESTIC_REPO_PASSWORD=
|
- RESTIC_PASSWORD=
|
||||||
- REFRESH_INTERVAL=1800 # 30 min
|
- REFRESH_INTERVAL=1800 # 30 min
|
||||||
volumes:
|
volumes:
|
||||||
- /host_path/restic/data:/data
|
- /host_path/restic/data:/data
|
||||||
|
|
|
@ -6,9 +6,9 @@ services:
|
||||||
container_name: restic-exporter
|
container_name: restic-exporter
|
||||||
environment:
|
environment:
|
||||||
- TZ=Europe/Madrid
|
- TZ=Europe/Madrid
|
||||||
- RESTIC_REPO_URL=/data
|
- RESTIC_REPOSITORY=/data
|
||||||
- RESTIC_REPO_PASSWORD=password_here
|
- RESTIC_PASSWORD=password_here
|
||||||
# - RESTIC_REPO_PASSWORD_FILE=/file_with_password_here
|
# - RESTIC_PASSWORD_FILE=/file_with_password_here
|
||||||
- REFRESH_INTERVAL=1800 # 30 min
|
- REFRESH_INTERVAL=1800 # 30 min
|
||||||
volumes:
|
volumes:
|
||||||
- /host_path/restic/data:/data
|
- /host_path/restic/data:/data
|
||||||
|
|
|
@ -3,14 +3,23 @@
|
||||||
# Exit on error. For debug use set -x
|
# Exit on error. For debug use set -x
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
if [ -z "${RESTIC_REPO_PASSWORD}" ]; then
|
if [ -n "${RESTIC_REPO_PASSWORD}" ]; then
|
||||||
if [ -z "${RESTIC_REPO_PASSWORD_FILE}" ]; then
|
echo "The environment variable RESTIC_REPO_PASSWORD is deprecated, please use RESTIC_PASSWORD instead."
|
||||||
echo "You have to define one of these environment variables: RESTIC_REPO_PASSWORD or RESTIC_REPO_PASSWORD_FILE"
|
export RESTIC_PASSWORD="${RESTIC_REPO_PASSWORD}"
|
||||||
|
fi
|
||||||
|
if [ -n "${RESTIC_REPO_PASSWORD_FILE}" ]; then
|
||||||
|
echo "The environment variable RESTIC_REPO_PASSWORD_FILE is deprecated, please use RESTIC_PASSWORD_FILE instead."
|
||||||
|
export RESTIC_PASSWORD_FILE="${RESTIC_REPO_PASSWORD_FILE}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${RESTIC_PASSWORD}" ]; then
|
||||||
|
if [ -z "${RESTIC_PASSWORD_FILE}" ]; then
|
||||||
|
echo "You have to define one of these environment variables: RESTIC_PASSWORD or RESTIC_PASSWORD_FILE"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
export RESTIC_REPO_PASSWORD_FILE="/tmp/restic_passwd"
|
export RESTIC_PASSWORD_FILE="/tmp/restic_passwd"
|
||||||
echo "${RESTIC_REPO_PASSWORD}" > "${RESTIC_REPO_PASSWORD_FILE}"
|
echo "${RESTIC_PASSWORD}" > "${RESTIC_PASSWORD_FILE}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
/usr/local/bin/python -u /restic-exporter.py
|
/usr/local/bin/python -u /restic-exporter.py
|
||||||
|
|
|
@ -347,16 +347,28 @@ if __name__ == "__main__":
|
||||||
logging.info("Starting Restic Prometheus Exporter")
|
logging.info("Starting Restic Prometheus Exporter")
|
||||||
logging.info("It could take a while if the repository is remote")
|
logging.info("It could take a while if the repository is remote")
|
||||||
|
|
||||||
try:
|
restic_repo_url = os.environ.get("RESTIC_REPOSITORY")
|
||||||
restic_repo_url = os.environ["RESTIC_REPO_URL"]
|
if restic_repo_url is None:
|
||||||
except Exception:
|
restic_repo_url = os.environ.get("RESTIC_REPO_URL")
|
||||||
logging.error("The environment variable RESTIC_REPO_URL is mandatory")
|
if restic_repo_url is not None:
|
||||||
|
logging.warning(
|
||||||
|
"The environment variable RESTIC_REPO_URL is deprecated, "
|
||||||
|
"please use RESTIC_REPOSITORY instead."
|
||||||
|
)
|
||||||
|
if restic_repo_url is None:
|
||||||
|
logging.error("The environment variable RESTIC_REPOSITORY is mandatory")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
try:
|
restic_repo_password_file = os.environ.get("RESTIC_PASSWORD_FILE")
|
||||||
restic_repo_password_file = os.environ["RESTIC_REPO_PASSWORD_FILE"]
|
if restic_repo_password_file is None:
|
||||||
except Exception:
|
restic_repo_password_file = os.environ.get("RESTIC_REPO_PASSWORD_FILE")
|
||||||
logging.error("The environment variable RESTIC_REPO_PASSWORD_FILE is mandatory")
|
if restic_repo_password_file is not None:
|
||||||
|
logging.warning(
|
||||||
|
"The environment variable RESTIC_REPO_PASSWORD_FILE is deprecated, "
|
||||||
|
"please use RESTIC_PASSWORD_FILE instead."
|
||||||
|
)
|
||||||
|
if restic_repo_password_file is None:
|
||||||
|
logging.error("The environment variable RESTIC_PASSWORD_FILE is mandatory")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
exporter_address = os.environ.get("LISTEN_ADDRESS", "0.0.0.0")
|
exporter_address = os.environ.get("LISTEN_ADDRESS", "0.0.0.0")
|
||||||
|
|
Loading…
Reference in a new issue