Compare commits
18 Commits
1b8e7fde9b
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| fb3bbe212d | |||
| e79bfbf384 | |||
| 11af5b8729 | |||
| 54fe3460b6 | |||
| 03c4aa8f83 | |||
| 2afc508157 | |||
| 4b7d6b8cd4 | |||
| bc4b4c322e | |||
| 9d48fc6d2d | |||
| 174b528899 | |||
| 90e90d64a2 | |||
| feeaf2e9d5 | |||
| 6d6b30d934 | |||
| a4e05c1f33 | |||
| 94db5c16d7 | |||
| 19f857e1fd | |||
| 9c5f9e8d30 | |||
| 734a6b99e0 |
7
.devcontainer/Dockerfile
Normal file
7
.devcontainer/Dockerfile
Normal 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
|
||||||
38
.devcontainer/devcontainer.json
Normal file
38
.devcontainer/devcontainer.json
Normal 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"
|
||||||
|
}
|
||||||
31
.gitea/workflows/docker-image.deploy.yml
Normal file
31
.gitea/workflows/docker-image.deploy.yml
Normal 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
12
.github/dependabot.yml
vendored
Normal 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
19
.vscode/settings.json
vendored
Normal 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"
|
||||||
|
// }
|
||||||
122
README.md
122
README.md
@@ -1,43 +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
|
## Scripts
|
||||||
|
|
||||||
|
Source: <https://github.com/duplicati/duplicati/blob/master/Duplicati/Library/Modules/Builtin/run-script-example.sh>
|
||||||
|
|
||||||
|
### mysql - dump backup
|
||||||
|
|
||||||
## Custom Docker Images
|
Duplicati options set `run-script-before-required` to [duplicati-mysql-backup](scripts/duplicati-mysql-backup).
|
||||||
|
|
||||||
### Duplicati with mySql Client
|
|
||||||
|
|
||||||
[+ Information](docker/mysqlclient/README.md)
|
|
||||||
|
|
||||||
|
|
||||||
## Send Mail
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
#for testing
|
MYSQL_HOST="mysqlserver"
|
||||||
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"
|
MYSQL_USER="msqluser"
|
||||||
|
MYSQL_PASSWORD="msqlpassord"
|
||||||
|
MYSQL_DATABASE="msqlpassword"
|
||||||
|
MYSQL_BACKUP_FOLDER="/var/db-dumps"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Influxdb Reporting
|
||||||
### Global Settings
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
#/etc/default/duplicati-influxdb
|
||||||
--send-mail-any-operation=true
|
INFLUXDB_SERVER=http://influxdb01.lan:8086
|
||||||
--send-mail-body=%RESULT%
|
INFLUXDB_BUCKET=bucketname
|
||||||
--send-mail-level=all
|
INFLUXDB_ORG=orgname
|
||||||
--send-mail-subject=Duplicati %OPERATIONNAME% report for -> %backup-name%
|
INFLUXDB_TOKEN=influxdbname
|
||||||
--send-mail-to=destination@mail.lan
|
#by default it uses client hostname in measurement field host
|
||||||
--send-http-result-output-format=Duplicati
|
#to override uncomment
|
||||||
--send-mail-url=smtp://serveraddress:25
|
#INFLUXDB_CLIENT_HOSTNAME=xxx
|
||||||
--send-mail-password=password
|
|
||||||
--send-mail-username=user@mail.lan
|
|
||||||
|
|
||||||
```
|
```
|
||||||
## Scripts
|
|
||||||
|
|
||||||
_Source: https://github.com/duplicati/duplicati/blob/master/Duplicati/Library/Modules/Builtin/run-script-example.sh_
|
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>_
|
||||||
|
|
||||||
- DUPLICATI__EVENTNAME
|
- DUPLICATI__EVENTNAME
|
||||||
|
|
||||||
@@ -65,8 +91,6 @@ _Source: https://github.com/duplicati/duplicati/blob/master/Duplicati/Library/Mo
|
|||||||
|
|
||||||
### Exit Codes
|
### Exit Codes
|
||||||
|
|
||||||
_Source: https://github.com/duplicati/duplicati/blob/master/Duplicati/Library/Modules/Builtin/run-script-example.sh_
|
|
||||||
|
|
||||||
The following exit codes are supported:
|
The following exit codes are supported:
|
||||||
|
|
||||||
- 0: OK, run operation
|
- 0: OK, run operation
|
||||||
@@ -76,3 +100,47 @@ The following exit codes are supported:
|
|||||||
- 4: Error, run operation
|
- 4: Error, run operation
|
||||||
- 5: Error don't run operation
|
- 5: Error don't run operation
|
||||||
- other: 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
17
docker/Dockerfile
Normal 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
34
docker/README.md
Normal 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:
|
||||||
|
```
|
||||||
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
#check ../README.md for more information
|
|
||||||
FROM duplicati/duplicati
|
|
||||||
RUN apt update && apt install -y default-mysql-client && rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
|
|
||||||
COPY /scripts/* /usr/local/bin
|
|
||||||
RUN chmod +x /usr/local/bin/duplicati-influxdb-notify
|
|
||||||
RUN chmod +x /usr/local/bin/duplicati-mysql-backup
|
|
||||||
|
|
||||||
EXPOSE 8200
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
# Duplicati / mySql Client
|
|
||||||
|
|
||||||
Using option run-script-before-required on duplicati job set value to /duplicati-mysqlclient/scripts/backupdb.sh.
|
|
||||||
And job will create a database dump configured using docker environment variables
|
|
||||||
|
|
||||||
## Build Image
|
|
||||||
|
|
||||||
### docker
|
|
||||||
|
|
||||||
```bash
|
|
||||||
|
|
||||||
#Executed on repository root folder
|
|
||||||
docker build -t duplicati-mysqlclient:latest -f docker/mysqlclient/Dockerfile .
|
|
||||||
|
|
||||||
```
|
|
||||||
### tar
|
|
||||||
|
|
||||||
```bash
|
|
||||||
#Executed on repository root folder
|
|
||||||
sudo docker build -t duplicati-mysqlclient:latest -f docker/mysqlclient/Dockerfile --output type=tar,dest=build/duplicati-mysqlclient.tar .
|
|
||||||
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
### Portainer
|
|
||||||
|
|
||||||
Images -> Build a new Image -> URL
|
|
||||||
|
|
||||||
**Name:** duplicati-mysqlclient:latest
|
|
||||||
|
|
||||||
**URL:** https://git.limbosolutions.com/kb/duplicati.git
|
|
||||||
|
|
||||||
**Dockerfile path:** docker/mysqlclient/Dockerfile
|
|
||||||
|
|
||||||
|
|
||||||
## Run Container
|
|
||||||
|
|
||||||
### Docker Compose
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
version: "3"
|
|
||||||
services:
|
|
||||||
duplicati:
|
|
||||||
image: duplicati-mysqlclient
|
|
||||||
environment:
|
|
||||||
- MYSQL_HOST=${MYSQL_HOST}
|
|
||||||
- MYSQL_DATABASE=${MYSQL_DATABASE}
|
|
||||||
- MYSQL_USER=${MYSQL_USER}
|
|
||||||
- MYSQL_PASSWORD=${MYSQL_PASSWORD}
|
|
||||||
- DESTINATION=/db-dumps
|
|
||||||
volumes:
|
|
||||||
- duplicati-data:/data
|
|
||||||
- db-dumps:/db-dumps
|
|
||||||
ports:
|
|
||||||
- 8200:8200
|
|
||||||
restart: unless-stopped
|
|
||||||
volumes:
|
|
||||||
duplicati-data:
|
|
||||||
db-dumps:
|
|
||||||
````
|
|
||||||
### Transfer To another system
|
|
||||||
1. Copy docker compose and execute on another system
|
|
||||||
2. Check volumes and service started succesfully
|
|
||||||
3. Stop all compose services
|
|
||||||
4. Change volume on duplicati service to user a temporary volume example (duclicati_tmpdata)
|
|
||||||
5. Check if all volumes are writable on duplication service
|
|
||||||
6. Start only the duplicati service (with temporary volume) on target system
|
|
||||||
7. On source system Stop app services on docker compose except duplicati
|
|
||||||
8. Execute a full backup ou source system
|
|
||||||
9. On target system execute a manual restore to original destination
|
|
||||||
10. Stop duplicati
|
|
||||||
11. Change duplicati to use original volume
|
|
||||||
12. And change volumes on duplicati to RO
|
|
||||||
13. Start all services
|
|
||||||
14. Check everything ok
|
|
||||||
|
|
||||||
### Environment Variables
|
|
||||||
10
docker/scripts/dockerlog
Normal file
10
docker/scripts/dockerlog
Normal 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
|
||||||
36
scripts/duplicati-influxdb-notify
Normal file → Executable file
36
scripts/duplicati-influxdb-notify
Normal file → Executable file
@@ -1,10 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#/etc/default/influxdb-connection example
|
|
||||||
#INFLUDB_SERVER=http://192.168.1.201:8086
|
|
||||||
#INFLUDB_BUCKET=bucketname
|
|
||||||
#INFLUDB_ORG=orgname
|
|
||||||
#INFLUDB_TOKEN=Token xxxx
|
|
||||||
if [ -f "/etc/default/duplicati-influxdb" ]; then
|
if [ -f "/etc/default/duplicati-influxdb" ]; then
|
||||||
export $(cat /etc/default/duplicati-influxdb)
|
export $(cat /etc/default/duplicati-influxdb)
|
||||||
fi
|
fi
|
||||||
@@ -13,15 +9,6 @@ if [ -f "~/.config/duplicati-influxdb" ]; then
|
|||||||
export $(cat ~/default/duplicati-influxdb)
|
export $(cat ~/default/duplicati-influxdb)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#duplicati
|
|
||||||
#DUPLICATI__EVENTNAME="zbf dc fbz"
|
|
||||||
#DUPLICATI__OPERATIONNAME="yy"
|
|
||||||
#DUPLICATI__PARSED_RESULT="p gfh uasd"
|
|
||||||
#DUPLICATI__backup_name="puggb"
|
|
||||||
#DUPLICATI__RESULTFILE="sd gasd"
|
|
||||||
#DUPLICATI__LOCALPATH="sagd"
|
|
||||||
#
|
|
||||||
|
|
||||||
TAGS=""
|
TAGS=""
|
||||||
MESSAGE_FIELD_VALUE=""
|
MESSAGE_FIELD_VALUE=""
|
||||||
|
|
||||||
@@ -33,13 +20,18 @@ escape_tag_str () {
|
|||||||
ESCAPED=${UNSCAPED//[ ]/\\ }
|
ESCAPED=${UNSCAPED//[ ]/\\ }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if [[ ! -z "$INFLUXDB_CLIENT_HOSTNAME" ]]; then
|
||||||
|
UNSCAPED=$INFLUXDB_CLIENT_HOSTNAME
|
||||||
if [[ ! -z "$HOSTNAME" ]]; then
|
escape_tag_str
|
||||||
|
TAGS="${TAGS},host=${ESCAPED}"
|
||||||
|
MESSAGE_FIELD_VALUE="${MESSAGE_FIELD_VALUE}${INFLUXDB_CLIENT_HOSTNAME} "
|
||||||
|
else
|
||||||
|
if [[ ! -z "$HOSTNAME" ]]; then
|
||||||
UNSCAPED=$HOSTNAME
|
UNSCAPED=$HOSTNAME
|
||||||
escape_tag_str
|
escape_tag_str
|
||||||
TAGS="${TAGS},host=${ESCAPED}"
|
TAGS="${TAGS},host=${ESCAPED}"
|
||||||
MESSAGE_FIELD_VALUE="${MESSAGE_FIELD_VALUE} ${HOSTNAME}"
|
MESSAGE_FIELD_VALUE="${MESSAGE_FIELD_VALUE}${HOSTNAME} "
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -z "$DUPLICATI__EVENTNAME" ]]; then
|
if [[ ! -z "$DUPLICATI__EVENTNAME" ]]; then
|
||||||
@@ -52,21 +44,21 @@ if [[ ! -z "$DUPLICATI__OPERATIONNAME" ]]; then
|
|||||||
UNSCAPED=$DUPLICATI__OPERATIONNAME
|
UNSCAPED=$DUPLICATI__OPERATIONNAME
|
||||||
escape_tag_str
|
escape_tag_str
|
||||||
TAGS="${TAGS},operationName=${ESCAPED}"
|
TAGS="${TAGS},operationName=${ESCAPED}"
|
||||||
MESSAGE_FIELD_VALUE="${MESSAGE_FIELD_VALUE} ${DUPLICATI__OPERATIONNAME}"
|
MESSAGE_FIELD_VALUE="${MESSAGE_FIELD_VALUE}${DUPLICATI__OPERATIONNAME} "
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -z "$DUPLICATI__backup_name" ]]; then
|
if [[ ! -z "$DUPLICATI__backup_name" ]]; then
|
||||||
UNSCAPED=$DUPLICATI__backup_name
|
UNSCAPED=$DUPLICATI__backup_name
|
||||||
escape_tag_str
|
escape_tag_str
|
||||||
TAGS="${TAGS},backupName=${ESCAPED}"
|
TAGS="${TAGS},backupName=${ESCAPED}"
|
||||||
MESSAGE_FIELD_VALUE="${MESSAGE_FIELD_VALUE} ${DUPLICATI__backup_name}"
|
MESSAGE_FIELD_VALUE="${MESSAGE_FIELD_VALUE}${DUPLICATI__backup_name} "
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -z "$DUPLICATI__PARSED_RESULT" ]]; then
|
if [[ ! -z "$DUPLICATI__PARSED_RESULT" ]]; then
|
||||||
UNSCAPED=$DUPLICATI__PARSED_RESULT
|
UNSCAPED=$DUPLICATI__PARSED_RESULT
|
||||||
escape_tag_str
|
escape_tag_str
|
||||||
TAGS="${TAGS},status=${ESCAPED}"
|
TAGS="${TAGS},status=${ESCAPED}"
|
||||||
MESSAGE_FIELD_VALUE="${MESSAGE_FIELD_VALUE} ${DUPLICATI__PARSED_RESULT}"
|
MESSAGE_FIELD_VALUE="${MESSAGE_FIELD_VALUE}${DUPLICATI__PARSED_RESULT} "
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -z "$DUPLICATI__RESULTFILE" ]]; then
|
if [[ ! -z "$DUPLICATI__RESULTFILE" ]]; then
|
||||||
@@ -81,7 +73,7 @@ if [[ ! -z "$DUPLICATI__LOCALPATH" ]]; then
|
|||||||
TAGS="${TAGS},localPath=${ESCAPED}"
|
TAGS="${TAGS},localPath=${ESCAPED}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
FIELDS="message=\"Duplicati ${MESSAGE_FIELD_VALUE}\""
|
FIELDS="message=\"${MESSAGE_FIELD_VALUE}\""
|
||||||
#echo $TAGS
|
#echo $TAGS
|
||||||
|
|
||||||
curl --request POST \
|
curl --request POST \
|
||||||
|
|||||||
29
scripts/duplicati-mysql-backup
Normal file → Executable file
29
scripts/duplicati-mysql-backup
Normal file → Executable file
@@ -1,16 +1,27 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# mysql database backup.
|
# mysql database backup.
|
||||||
# executed by duplicati run-script-before-required
|
# executed by duplicati run-script-before-required
|
||||||
# required environment variables:
|
# required environment variables:
|
||||||
# DESTINATION
|
|
||||||
# MYSQL_HOST
|
# MYSQL_HOST
|
||||||
# MYSQL_USER
|
# MYSQL_USER
|
||||||
# MYSQL_PASSWORD
|
# MYSQL_PASSWORD
|
||||||
# MYSQL_DATABASE
|
# MYSQL_DATABASE
|
||||||
|
# MYSQL_BACKUP_FOLDER
|
||||||
|
|
||||||
#any error must stop execution
|
#any error must stop execution
|
||||||
set -e
|
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" ]
|
if [ $DUPLICATI__OPERATIONNAME == "Backup" ]
|
||||||
then
|
then
|
||||||
echo "Backup Job!!"
|
echo "Backup Job!!"
|
||||||
@@ -20,12 +31,12 @@ else
|
|||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -z "$MYSQL_BACKUP_FOLDER" ]; then
|
||||||
|
MYSQL_BACKUP_FOLDER="/var/db-dumps"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z ${DESTINATION} ]
|
if [ ! -d $MYSQL_BACKUP_FOLDER ]; then
|
||||||
then
|
mkdir -p $MYSQL_BACKUP_FOLDER;
|
||||||
echo "\$DESTINATION environment variable cannot be empty empty"
|
|
||||||
#5: Error don't run operation
|
|
||||||
exit 5
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
TARGETFILENAME=${MYSQL_DATABASE}_dump_$(date -d "today" +"%Y%m%d%H%M%S").sql
|
TARGETFILENAME=${MYSQL_DATABASE}_dump_$(date -d "today" +"%Y%m%d%H%M%S").sql
|
||||||
@@ -40,10 +51,10 @@ fi
|
|||||||
mysqldump -h ${MYSQL_HOST} --user=${MYSQL_USER} -p"${MYSQL_PASSWORD}" ${MYSQL_DATABASE} > /tmp/${TARGETFILENAME}
|
mysqldump -h ${MYSQL_HOST} --user=${MYSQL_USER} -p"${MYSQL_PASSWORD}" ${MYSQL_DATABASE} > /tmp/${TARGETFILENAME}
|
||||||
|
|
||||||
|
|
||||||
if [ x$(find "$DESTINATION" -prune -empty) = x"$DESTINATION" ]; then
|
if [ x$(find "$MYSQL_BACKUP_FOLDER" -prune -empty) = x"$MYSQL_BACKUP_FOLDER" ]; then
|
||||||
echo "folder is empty... ignoring clean db dump folder"
|
echo "folder is empty... ignoring clean db dump folder"
|
||||||
else
|
else
|
||||||
rm -r ${DESTINATION}/*
|
rm -r ${MYSQL_BACKUP_FOLDER}/*
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mv /tmp/${TARGETFILENAME} ${DESTINATION}/${TARGETFILENAME}
|
mv /tmp/${TARGETFILENAME} ${MYSQL_BACKUP_FOLDER}/${TARGETFILENAME}
|
||||||
|
|||||||
Reference in New Issue
Block a user