Compare commits

..

42 Commits

Author SHA1 Message Date
fb3bbe212d removed datetime from docker log output
All checks were successful
/ build-docker-image (push) Successful in 50s
2025-01-28 19:56:01 +00:00
e79bfbf384 revision
All checks were successful
/ build-docker-image (push) Successful in 24s
2025-01-20 20:16:51 +00:00
11af5b8729 docker context revision
All checks were successful
/ build-docker-image (push) Successful in 1m21s
2024-09-16 20:30:10 +01:00
54fe3460b6 fix docker file
Some checks failed
/ build-docker-image (push) Failing after 12s
2024-09-16 19:53:11 +01:00
03c4aa8f83 fix CDI 2
Some checks failed
/ build-docker-image (push) Failing after 40s
2024-09-16 19:50:04 +01:00
2afc508157 fix ci
Some checks failed
/ build-docker-image (push) Failing after 10s
2024-09-16 19:48:39 +01:00
4b7d6b8cd4 continous integration
Some checks failed
/ build-docker-image (push) Failing after 12s
2024-09-16 19:45:00 +01:00
bc4b4c322e Update README.md 2024-04-01 15:12:01 +00:00
9d48fc6d2d docker log message revision 2024-03-16 23:57:45 +00:00
174b528899 added docker log 2024-03-16 23:39:58 +00:00
90e90d64a2 fix: message impr 2023-06-10 09:59:24 +01:00
feeaf2e9d5 feat: added INFLUXDB_CLIENT_HOSTNAME to influxdb report 2023-06-10 09:48:02 +01:00
6d6b30d934 fix: script error 2023-06-10 09:31:25 +01:00
a4e05c1f33 fix: encoding problems 2023-06-10 09:11:59 +01:00
94db5c16d7 fix: small fixes 2023-06-10 08:57:16 +01:00
19f857e1fd feat: influxdb reporting
Reviewed-on: #2
2023-06-10 07:34:24 +00:00
9c5f9e8d30 . 2023-06-10 07:57:39 +01:00
734a6b99e0 . 2023-06-10 07:38:17 +01:00
1b8e7fde9b . 2023-06-10 05:02:55 +01:00
f5c52389e6 . 2023-06-10 05:02:31 +01:00
a4458133f3 production 2023-05-30 21:10:03 +00:00
6cc1a4f88a doc: send mail 2023-03-06 17:37:27 +00:00
37b4982a24 Update 'docker/mysqlclient/scripts/backupdb.sh' 2022-10-10 22:23:08 +00:00
c6ffe5c880 Update 'docker/mysqlclient/scripts/backupdb.sh' 2022-10-09 16:33:46 +01:00
244e6e365d Merge branch 'topic/dockerfile' into main 2022-10-09 16:27:37 +01:00
8a22e27d3a Update 'docker/mysqlclient/scripts/backupdb.sh' 2022-10-09 16:23:16 +01:00
a771b44a57 Update 'docker/mysqlclient/scripts/backupdb.sh' 2022-10-09 16:20:15 +01:00
a370a68bff Update 'docker/mysqlclient/scripts/backupdb.sh' 2022-10-09 16:15:26 +01:00
11c49087fc Update 'docker/mysqlclient/Dockerfile' 2022-10-09 16:07:21 +01:00
6c771c2f60 Update 'docker/mysqlclient/Dockerfile' 2022-10-09 15:52:55 +01:00
695dbc7804 Update 'docker/mysqlclient/scripts/backupdb.sh' 2022-10-09 15:50:37 +01:00
6c45cf36cd . 2022-10-09 15:34:59 +01:00
53c5f682c9 . 2022-10-09 15:33:42 +01:00
b21c6e6256 . 2022-10-09 15:32:20 +01:00
717fd6ae8f . 2022-10-09 15:05:58 +01:00
e09f0324b3 . 2022-10-09 15:04:08 +01:00
2d54e09ac0 . 2022-10-09 15:02:22 +01:00
da49757a64 . 2022-10-09 14:59:39 +01:00
2a8f3daf08 . 2022-10-09 14:15:23 +01:00
6b2ea052e2 - 2022-10-09 12:46:10 +01:00
3b0101a983 . 2022-10-09 12:44:09 +01:00
53965d1f7a . 2022-10-09 12:30:07 +01:00
13 changed files with 418 additions and 63 deletions

7
.devcontainer/Dockerfile Normal file
View File

@@ -0,0 +1,7 @@
FROM duplicati/duplicati
RUN apt update && \
apt install -y default-mysql-client && \
rm -rf /var/lib/apt/lists/*
EXPOSE 8200

View File

@@ -0,0 +1,38 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu
{
"name": "duplicati_dev-container",
"build": {
// Path is relative to the devcontainer.json file.
"dockerfile": "Dockerfile"
},
"features": {
"ghcr.io/devcontainers/features/git:1": {
"ppa": true,
"version": "latest"
},
"ghcr.io/prulloac/devcontainer-features/gitlint:1": {}
},
"containerEnv": {}
//"features": {
// "ghcr.io/wxw-matt/devcontainer-features/command_runner:0": {},
// "ghcr.io/wxw-matt/devcontainer-features/script_runner:0": {},
// "ghcr.io/devcontainers-extra/features/act:1": {}
// }
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "uname -a",
// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}

View File

@@ -0,0 +1,31 @@
on:
push:
paths:
- "docker/**"
- ".gitea/**"
- "scripts/**"
jobs:
build-docker-image:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Log in to git.limbosolutions.com docker registry
uses: docker/login-action@v3
with:
registry: git.limbosolutions.com
username: ${{ secrets.GITLIMBO_DOCKER_REGISTRY_USERNAME }}
password: ${{ secrets.GITLIMBO_DOCKER_REGISTRY_PASSWORD }}
- name: Build and push Docker images
id: push
uses: docker/build-push-action@v6
with:
context: ${{gitea.workspace}}
file: ${{gitea.workspace}}/docker/Dockerfile
push: true
tags: git.limbosolutions.com/kb/duplicati:latest

12
.github/dependabot.yml vendored Normal file
View File

@@ -0,0 +1,12 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for more information:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
# https://containers.dev/guide/dependabot
version: 2
updates:
- package-ecosystem: "devcontainers"
directory: "/"
schedule:
interval: weekly

19
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,19 @@
{
"docker.commands.composeUpSubset": [
{
"label": "Compose Up",
"template": "${composeCommand} ${profileList} ${configurationFile} up ${detached} ${build} ${serviceList}"
}
],
"docker.commands.composeUp": [
{
"label": "Compose Up",
"template": "${composeCommand} ${configurationFile} up ${detached} ${build}"
}
],
"docker.contexts.showInStatusBar": true
} // {
// "docker.commands.build": "${containerCommand} build --pull --rm -f \"${dockerfile}\" -t ${tag} . --progress=plain"
// }

108
README.md
View File

@@ -1,11 +1,69 @@
# duplicati
# Duplicati
- [Docker](#docker)
- [Duplicati/mySql Client - image](#duplicatimysql-client---image)
- [Scripts](#scripts)
- [mysql - dump backup](#mysql---dump-backup)
- [Influxdb Reporting](#influxdb-reporting)
- [Docker log](#docker-log)
- [Environment Variables](#environment-variables)
- [Exit Codes](#exit-codes)
- [cli](#cli)
- [Send Mail](#send-mail)
- [Settings](#settings)
- [Send Email](#send-email)
- [nginx](#nginx)
## Docker
### Duplicati/mySql Client - image
Image contains all scripts
[+ Information](docker/README.md)
## Scripts
Source: <https://github.com/duplicati/duplicati/blob/master/Duplicati/Library/Modules/Builtin/run-script-example.sh>
### mysql - dump backup
Duplicati options set `run-script-before-required` to [duplicati-mysql-backup](scripts/duplicati-mysql-backup).
```bash
MYSQL_HOST="mysqlserver"
MYSQL_USER="msqluser"
MYSQL_PASSWORD="msqlpassord"
MYSQL_DATABASE="msqlpassword"
MYSQL_BACKUP_FOLDER="/var/db-dumps"
```
### Influxdb Reporting
```bash
#/etc/default/duplicati-influxdb
INFLUXDB_SERVER=http://influxdb01.lan:8086
INFLUXDB_BUCKET=bucketname
INFLUXDB_ORG=orgname
INFLUXDB_TOKEN=influxdbname
#by default it uses client hostname in measurement field host
#to override uncomment
#INFLUXDB_CLIENT_HOSTNAME=xxx
```
Add [script](scripts/duplicati-influxdb-notify) to default settings.
Example:
--run-script-after=duplicati-influxdb-notify
### Docker log
Add [script](docker/scripts/dockerlog) to default settings.
Example:
--run-script-after=dockerlog
### Environment Variables
_Source: https://github.com/duplicati/duplicati/blob/master/Duplicati/Library/Modules/Builtin/run-script-example.sh_
Source: <https://github.com/duplicati/duplicati/blob/master/Duplicati/Library/Modules/Builtin/run-script-example.sh>_
- DUPLICATI__EVENTNAME
@@ -33,8 +91,6 @@ _Source: https://github.com/duplicati/duplicati/blob/master/Duplicati/Library/Mo
### Exit Codes
_Source: https://github.com/duplicati/duplicati/blob/master/Duplicati/Library/Modules/Builtin/run-script-example.sh_
The following exit codes are supported:
- 0: OK, run operation
@@ -44,3 +100,47 @@ The following exit codes are supported:
- 4: Error, run operation
- 5: Error don't run operation
- other: Error don't run operation
## cli
## Send Mail
```bash
#for testing
duplicati-cli send-mail --send-mail-password="pass" --send-mail-to="target@mail.lan" --send-mail-username="suer@mail.lan" --send-mail-url="smtp://serveraddress:25"
```
## Settings
### Send Email
```bash
--send-mail-any-operation=true
--send-mail-body=%RESULT%
--send-mail-level=all
--send-mail-subject=Duplicati %OPERATIONNAME% report for -> %backup-name%
--send-mail-to=destination@mail.lan
--send-http-result-output-format=Duplicati
--send-mail-url=smtp://serveraddress:25
--send-mail-password=password
--send-mail-username=user@mail.lan
```
## nginx
Example running on _duplicati sub folder
```bash
location /_duplicati/ {
proxy_pass http://<duplicatiserver>:8200/;
proxy_redirect ~^/(.*) $scheme://$http_host/_duplicati/$1;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Protocol $scheme;
proxy_set_header X-Url-Scheme $scheme;
}
```

17
docker/Dockerfile Normal file
View File

@@ -0,0 +1,17 @@
FROM duplicati/duplicati
RUN apt update && \
apt install -y default-mysql-client && \
rm -rf /var/lib/apt/lists/*
#repo root scripts
COPY /docker/scripts /usr/local/bin
#docker scripts
COPY ./scripts /usr/local/bin
RUN \
chmod +x /usr/local/bin/duplicati-influxdb-notify; \
chmod +x /usr/local/bin/duplicati-mysql-backup; \
chmod +x /usr/local/bin/dockerlog
EXPOSE 8200

34
docker/README.md Normal file
View File

@@ -0,0 +1,34 @@
# Duplicati / mySql Client
- [Docker Compose](#docker-compose)
- [Development](#development)
- [Docker Build](#docker-build)
## Docker Compose
```yaml
version: "3"
services:
duplicati:
image: git.limbosolutions.com/kb/duplicati:mysql-latest
environment:
- MYSQL_HOST=${MYSQL_HOST}
- MYSQL_DATABASE=${MYSQL_DATABASE}
- MYSQL_USER=${MYSQL_USER}
- MYSQL_PASSWORD=${MYSQL_PASSWORD}
- INFLUXDB_SERVER=${INFLUXDB_SERVER}
- INFLUXDB_BUCKET=${INFLUXDB_BUCKET}
- INFLUXDB_ORG=${INFLUXDB_ORG}
- INFLUXDB_TOKEN=${INFLUXDB_TOKEN}
- INFLUXDB_CLIENT_HOSTNAME=${INFLUXDB_CLIENT_HOSTNAME}
volumes:
- duplicati-data:/data
- db-dumps:/db-dumps
ports:
- 8200:8200
restart: unless-stopped
volumes:
duplicati-data:
db-dumps:
```

10
docker/scripts/dockerlog Normal file
View File

@@ -0,0 +1,10 @@
#!/bin/bash
#printf $(date '+%Y-%m-%d') >> /proc/1/fd/1;
#printf " " >> /proc/1/fd/1;
#printf $(date '+%H:%M:%S') >> /proc/1/fd/1;
printf "INFO:" >> /proc/1/fd/1;
printf " %s" $DUPLICATI__OPERATIONNAME >> /proc/1/fd/1;
printf " %s" $DUPLICATI__PARSED_RESULT >> /proc/1/fd/1;
printf " %s" $DUPLICATI__backup_name >> /proc/1/fd/1;
printf " %s" $DUPLICATI__LOCALPATH >> /proc/1/fd/1;
printf "\n" >> /proc/1/fd/1

View File

@@ -1,9 +0,0 @@
FROM duplicati/duplicati
RUN apt update && apt install -y default-mysql-client && rm -rf /var/lib/apt/lists/*
EXPOSE 8200
#RUN mkdir duplicati-sqlclient/scripts
#COPY /docker/sqlclient/scripts/* /duplicati-sqlclient/scripts/
#EXPOSE 8200

View File

@@ -1,50 +0,0 @@
#!/bin/bash
# mysql database backup.
# executed by duplicati run-script-before-required
# required environment variables:
# DESTINATION
# DB_HOST
# DB_USER
# DB_PASSWORD
# DB_NAME
# download directly from git
# curl https://git.limbosolutions.com/kb/duplicati/raw/branch/main/docker/scripts/backupdb.sh > backupdb.sh | chmod +x backupdb.sh
#any error must stop execution
set -e
if [ $DUPLICATI__OPERATIONNAME != "Backup" ]
then
echo "Not a backup operation. exiting!"
#OK, run operation
return 0
fi
if [ -z ${DESTINATION} ]
then
echo "\$DESTINATION cannot be empty empty"
#5: Error don't run operation
exit 5
fi
TARGETFILENAME=${DB_NAME}_dump_$(date -d "today" +"%Y%m%d%H%M%S").sql
echo "dump file name:$TARGETFILENAME"
if [ -f /tmp/${TARGETFILENAME} ]
then
rm /tmp/${TARGETFILENAME}
fi
mysqldump -h ${DB_HOST} --user=${DB_USER} -p"${DB_PASSWORD}" ${DB_NAME} > /tmp/${TARGETFILENAME}
if [ x$(find "$DB_BACKUP_TARGETFOLDER" -prune -empty) = x"$DB_BACKUP_TARGETFOLDER" ]; then
echo "folder is empty... ignoring clean db dump folder"
else
rm -r ${DB_BACKUP_TARGETFOLDER} /*
fi
mv /tmp/${TARGETFILENAME} ${DB_BACKUP_TARGETFOLDER}/${TARGETFILENAME}
return 0

View File

@@ -0,0 +1,86 @@
#!/bin/bash
if [ -f "/etc/default/duplicati-influxdb" ]; then
export $(cat /etc/default/duplicati-influxdb)
fi
if [ -f "~/.config/duplicati-influxdb" ]; then
export $(cat ~/default/duplicati-influxdb)
fi
TAGS=""
MESSAGE_FIELD_VALUE=""
UNSCAPED=""
ESCAPED=""
escape_tag_str () {
ESCAPED=${UNSCAPED//[ ]/\\ }
}
if [[ ! -z "$INFLUXDB_CLIENT_HOSTNAME" ]]; then
UNSCAPED=$INFLUXDB_CLIENT_HOSTNAME
escape_tag_str
TAGS="${TAGS},host=${ESCAPED}"
MESSAGE_FIELD_VALUE="${MESSAGE_FIELD_VALUE}${INFLUXDB_CLIENT_HOSTNAME} "
else
if [[ ! -z "$HOSTNAME" ]]; then
UNSCAPED=$HOSTNAME
escape_tag_str
TAGS="${TAGS},host=${ESCAPED}"
MESSAGE_FIELD_VALUE="${MESSAGE_FIELD_VALUE}${HOSTNAME} "
fi
fi
if [[ ! -z "$DUPLICATI__EVENTNAME" ]]; then
UNSCAPED=$DUPLICATI__EVENTNAME
escape_tag_str
TAGS="${TAGS},eventName=\"${ESCAPED}\""
fi
if [[ ! -z "$DUPLICATI__OPERATIONNAME" ]]; then
UNSCAPED=$DUPLICATI__OPERATIONNAME
escape_tag_str
TAGS="${TAGS},operationName=${ESCAPED}"
MESSAGE_FIELD_VALUE="${MESSAGE_FIELD_VALUE}${DUPLICATI__OPERATIONNAME} "
fi
if [[ ! -z "$DUPLICATI__backup_name" ]]; then
UNSCAPED=$DUPLICATI__backup_name
escape_tag_str
TAGS="${TAGS},backupName=${ESCAPED}"
MESSAGE_FIELD_VALUE="${MESSAGE_FIELD_VALUE}${DUPLICATI__backup_name} "
fi
if [[ ! -z "$DUPLICATI__PARSED_RESULT" ]]; then
UNSCAPED=$DUPLICATI__PARSED_RESULT
escape_tag_str
TAGS="${TAGS},status=${ESCAPED}"
MESSAGE_FIELD_VALUE="${MESSAGE_FIELD_VALUE}${DUPLICATI__PARSED_RESULT} "
fi
if [[ ! -z "$DUPLICATI__RESULTFILE" ]]; then
UNSCAPED=$DUPLICATI__RESULTFILE
escape_tag_str
TAGS="${TAGS},resultFile=${ESCAPED}"
fi
if [[ ! -z "$DUPLICATI__LOCALPATH" ]]; then
UNSCAPED=$DUPLICATI__LOCALPATH
escape_tag_str
TAGS="${TAGS},localPath=${ESCAPED}"
fi
FIELDS="message=\"${MESSAGE_FIELD_VALUE}\""
#echo $TAGS
curl --request POST \
"$INFLUXDB_SERVER/write?db=$INFLUXDB_BUCKET&ORG=$INFLUXDB_ORG" \
--header "Authorization: Token $INFLUXDB_TOKEN" \
--header "Content-Type: text/plain; charset=utf-8" \
--header "Accept: application/json" \
--data-raw "duplicati${TAGS} ${FIELDS}" > /dev/null 2>&1
exit 0

60
scripts/duplicati-mysql-backup Executable file
View File

@@ -0,0 +1,60 @@
#!/bin/bash
# mysql database backup.
# executed by duplicati run-script-before-required
# required environment variables:
# MYSQL_HOST
# MYSQL_USER
# MYSQL_PASSWORD
# MYSQL_DATABASE
# MYSQL_BACKUP_FOLDER
#any error must stop execution
set -e
if [ -f "/etc/default/duplicati-mysql" ]; then
export $(cat /etc/default/duplicati-mysql)
fi
if [ -f "~/.config/duplicati-mysql" ]; then
export $(cat ~/default/duplicati-mysql)
fi
if [ $DUPLICATI__OPERATIONNAME == "Backup" ]
then
echo "Backup Job!!"
else
echo "Not a backup operation. exiting!"
#OK, run operation
exit
fi
if [ -z "$MYSQL_BACKUP_FOLDER" ]; then
MYSQL_BACKUP_FOLDER="/var/db-dumps"
fi
if [ ! -d $MYSQL_BACKUP_FOLDER ]; then
mkdir -p $MYSQL_BACKUP_FOLDER;
fi
TARGETFILENAME=${MYSQL_DATABASE}_dump_$(date -d "today" +"%Y%m%d%H%M%S").sql
echo "dump file name:$TARGETFILENAME"
if [ -f /tmp/${TARGETFILENAME} ]
then
rm /tmp/${TARGETFILENAME}
fi
mysqldump -h ${MYSQL_HOST} --user=${MYSQL_USER} -p"${MYSQL_PASSWORD}" ${MYSQL_DATABASE} > /tmp/${TARGETFILENAME}
if [ x$(find "$MYSQL_BACKUP_FOLDER" -prune -empty) = x"$MYSQL_BACKUP_FOLDER" ]; then
echo "folder is empty... ignoring clean db dump folder"
else
rm -r ${MYSQL_BACKUP_FOLDER}/*
fi
mv /tmp/${TARGETFILENAME} ${MYSQL_BACKUP_FOLDER}/${TARGETFILENAME}