production
This commit is contained in:
168
README.md
168
README.md
@@ -1,77 +1,91 @@
|
|||||||
# Duplicati
|
# Duplicati
|
||||||
|
|
||||||
## Custom Docker Images
|
## Custom Docker Images
|
||||||
|
|
||||||
### Duplicati with mySql Client
|
### Duplicati with mySql Client
|
||||||
|
|
||||||
[+ Information](docker/mysqlclient/README.md)
|
[+ Information](docker/mysqlclient/README.md)
|
||||||
|
|
||||||
|
|
||||||
## Send Mail
|
## Send Mail
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
#for testing
|
#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"
|
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"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### Global Settings
|
### Global Settings
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|
||||||
--send-mail-any-operation=true
|
--send-mail-any-operation=true
|
||||||
--send-mail-body=%RESULT%
|
--send-mail-body=%RESULT%
|
||||||
--send-mail-level=all
|
--send-mail-level=all
|
||||||
--send-mail-subject=Duplicati %OPERATIONNAME% report for -> %backup-name%
|
--send-mail-subject=Duplicati %OPERATIONNAME% report for -> %backup-name%
|
||||||
--send-mail-to=destination@mail.lan
|
--send-mail-to=destination@mail.lan
|
||||||
--send-http-result-output-format=Duplicati
|
--send-http-result-output-format=Duplicati
|
||||||
--send-mail-url=smtp://serveraddress:25
|
--send-mail-url=smtp://serveraddress:25
|
||||||
--send-mail-password=password
|
--send-mail-password=password
|
||||||
--send-mail-username=user@mail.lan
|
--send-mail-username=user@mail.lan
|
||||||
|
|
||||||
```
|
```
|
||||||
|
## Scripts
|
||||||
## Scripts
|
|
||||||
|
### Transfer To another system
|
||||||
|
1. Copy docker compose and execute on another system
|
||||||
### Environment Variables
|
2. Check volumes and service started succesfully
|
||||||
|
3. Stop all compose services
|
||||||
_Source: https://github.com/duplicati/duplicati/blob/master/Duplicati/Library/Modules/Builtin/run-script-example.sh_
|
4. Change volume on duplicati service to user a temporary volume example (duclicati_tmpdata)
|
||||||
|
5. Check if all volumes are writable on duplication service
|
||||||
- DUPLICATI__EVENTNAME
|
6. Start only the duplicati service (with temporary volume) on target system
|
||||||
|
7. On source system Stop app services on docker compose except duplicati
|
||||||
Eventname is BEFORE if invoked as --run-script-before, and AFTER if invoked as --run-script-after. This value cannot be changed by writing it back!
|
8. Execute a full backup ou source system
|
||||||
|
9. On target system execute a manual restore to original destination
|
||||||
- DUPLICATI__OPERATIONNAME
|
10. Stop duplicati
|
||||||
|
11. Change duplicati to use original volume
|
||||||
Operation name can be any of the operations that Duplicati supports. For example it can be "Backup", "Cleanup", "Restore", or "DeleteAllButN". This value cannot be changed by writing it back!
|
12. And change volumes on duplicati to RO
|
||||||
|
13. Start all services
|
||||||
- DUPLICATI__RESULTFILE
|
14. Check everything ok
|
||||||
|
|
||||||
If invoked as --run-script-after this will contain the name of the file where result data is placed. This value cannot be changed by writing it back!
|
### Environment Variables
|
||||||
|
|
||||||
- DUPLICATI__REMOTEURL
|
_Source: https://github.com/duplicati/duplicati/blob/master/Duplicati/Library/Modules/Builtin/run-script-example.sh_
|
||||||
|
|
||||||
This is the remote url for the target backend. This value can be changed by echoing --remoteurl = "new value".
|
- DUPLICATI__EVENTNAME
|
||||||
|
|
||||||
- DUPLICATI__LOCALPATH
|
Eventname is BEFORE if invoked as --run-script-before, and AFTER if invoked as --run-script-after. This value cannot be changed by writing it back!
|
||||||
|
|
||||||
This is the path to the folders being backed up or restored. This variable is empty operations other than backup or restore. The local path can contain : to separate multiple folders. This value can be changed by echoing --localpath = "new value".
|
- DUPLICATI__OPERATIONNAME
|
||||||
|
|
||||||
- DUPLICATI__PARSED_RESULT
|
Operation name can be any of the operations that Duplicati supports. For example it can be "Backup", "Cleanup", "Restore", or "DeleteAllButN". This value cannot be changed by writing it back!
|
||||||
|
|
||||||
This is a value indicating how well the operation was performed. It can take the values: Unknown, Success, Warning, Error, Fatal.
|
- DUPLICATI__RESULTFILE
|
||||||
|
|
||||||
### Exit Codes
|
If invoked as --run-script-after this will contain the name of the file where result data is placed. This value cannot be changed by writing it back!
|
||||||
|
|
||||||
_Source: https://github.com/duplicati/duplicati/blob/master/Duplicati/Library/Modules/Builtin/run-script-example.sh_
|
- DUPLICATI__REMOTEURL
|
||||||
|
|
||||||
The following exit codes are supported:
|
This is the remote url for the target backend. This value can be changed by echoing --remoteurl = "new value".
|
||||||
|
|
||||||
- 0: OK, run operation
|
- DUPLICATI__LOCALPATH
|
||||||
- 1: OK, don't run operation
|
|
||||||
- 2: Warning, run operation
|
This is the path to the folders being backed up or restored. This variable is empty operations other than backup or restore. The local path can contain : to separate multiple folders. This value can be changed by echoing --localpath = "new value".
|
||||||
- 3: Warning, don't run operation
|
|
||||||
- 4: Error, run operation
|
- DUPLICATI__PARSED_RESULT
|
||||||
- 5: Error don't run operation
|
|
||||||
- other: Error don't run operation
|
This is a value indicating how well the operation was performed. It can take the values: Unknown, Success, Warning, Error, Fatal.
|
||||||
|
|
||||||
|
### 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
|
||||||
|
- 1: OK, don't run operation
|
||||||
|
- 2: Warning, run operation
|
||||||
|
- 3: Warning, don't run operation
|
||||||
|
- 4: Error, run operation
|
||||||
|
- 5: Error don't run operation
|
||||||
|
- other: Error don't run operation
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#check ../README.md for more information
|
#check ../README.md for more information
|
||||||
|
|
||||||
FROM duplicati/duplicati
|
FROM duplicati/duplicati
|
||||||
RUN apt update && apt install -y default-mysql-client && rm -rf /var/lib/apt/lists/*
|
RUN apt update && apt install -y default-mysql-client && rm -rf /var/lib/apt/lists/*
|
||||||
RUN mkdir duplicati-mysqlclient
|
RUN mkdir duplicati-mysqlclient
|
||||||
RUN mkdir duplicati-mysqlclient/scripts
|
RUN mkdir duplicati-mysqlclient/scripts
|
||||||
COPY /docker/mysqlclient/scripts/* /duplicati-mysqlclient/scripts/
|
COPY /docker/mysqlclient/scripts/* /duplicati-mysqlclient/scripts/
|
||||||
RUN chmod +x /duplicati-mysqlclient/scripts/*
|
RUN chmod +x /duplicati-mysqlclient/scripts/*
|
||||||
EXPOSE 8200
|
EXPOSE 8200
|
||||||
@@ -1,47 +1,60 @@
|
|||||||
# Duplicati / mySql Client
|
# Duplicati / mySql Client
|
||||||
|
|
||||||
Using option run-script-before-required on duplicati job set value to /duplicati-mysqlclient/scripts/backupdb.sh.
|
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
|
And job will create a database dump configured using docker environment variables
|
||||||
|
|
||||||
## Build Image
|
## Build Image
|
||||||
|
|
||||||
```bash
|
### docker
|
||||||
#Executed on repository root folder
|
|
||||||
docker build -t duplicati-mysqlclient:latest -f docker/mysqlclient/Dockerfile .
|
```bash
|
||||||
```
|
|
||||||
|
#Executed on repository root folder
|
||||||
### Portainer
|
docker build -t duplicati-mysqlclient:latest -f docker/mysqlclient/Dockerfile .
|
||||||
|
|
||||||
Images -> Build a new Image -> URL
|
```
|
||||||
|
### tar
|
||||||
**Name:** duplicati-mysqlclient:latest
|
|
||||||
|
```bash
|
||||||
**URL:** https://git.limbosolutions.com/kb/duplicati.git
|
#Executed on repository root folder
|
||||||
|
sudo docker build -t duplicati-mysqlclient:latest -f docker/mysqlclient/Dockerfile --output type=tar,dest=build/duplicati-mysqlclient.tar .
|
||||||
**Dockerfile path:** docker/mysqlclient/Dockerfile
|
|
||||||
|
|
||||||
## Run Container
|
```
|
||||||
|
|
||||||
### Docker Compose
|
### Portainer
|
||||||
|
|
||||||
```yaml
|
Images -> Build a new Image -> URL
|
||||||
version: "3"
|
|
||||||
services:
|
**Name:** duplicati-mysqlclient:latest
|
||||||
duplicati:
|
|
||||||
image: duplicati-mysqlclient
|
**URL:** https://git.limbosolutions.com/kb/duplicati.git
|
||||||
environment:
|
|
||||||
- MYSQL_HOST=${MYSQL_HOST}
|
**Dockerfile path:** docker/mysqlclient/Dockerfile
|
||||||
- MYSQL_DATABASE=${MYSQL_DATABASE}
|
|
||||||
- MYSQL_USER=${MYSQL_USER}
|
|
||||||
- MYSQL_PASSWORD=${MYSQL_PASSWORD}
|
## Run Container
|
||||||
- DESTINATION=/db-dumps
|
|
||||||
volumes:
|
### Docker Compose
|
||||||
- duplicati-data:/data
|
|
||||||
- db-dumps:/db-dumps
|
```yaml
|
||||||
ports:
|
version: "3"
|
||||||
- 8200:8200
|
services:
|
||||||
restart: unless-stopped
|
duplicati:
|
||||||
volumes:
|
image: duplicati-mysqlclient
|
||||||
duplicati-data:
|
environment:
|
||||||
db-dumps:
|
- 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:
|
||||||
|
````
|
||||||
|
|||||||
@@ -1,49 +1,49 @@
|
|||||||
#!/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
|
# DESTINATION
|
||||||
# MYSQL_HOST
|
# MYSQL_HOST
|
||||||
# MYSQL_USER
|
# MYSQL_USER
|
||||||
# MYSQL_PASSWORD
|
# MYSQL_PASSWORD
|
||||||
# MYSQL_DATABASE
|
# MYSQL_DATABASE
|
||||||
|
|
||||||
#any error must stop execution
|
#any error must stop execution
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
if [ $DUPLICATI__OPERATIONNAME == "Backup" ]
|
if [ $DUPLICATI__OPERATIONNAME == "Backup" ]
|
||||||
then
|
then
|
||||||
echo "Backup Job!!"
|
echo "Backup Job!!"
|
||||||
else
|
else
|
||||||
echo "Not a backup operation. exiting!"
|
echo "Not a backup operation. exiting!"
|
||||||
#OK, run operation
|
#OK, run operation
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
if [ -z ${DESTINATION} ]
|
if [ -z ${DESTINATION} ]
|
||||||
then
|
then
|
||||||
echo "\$DESTINATION environment variable cannot be empty empty"
|
echo "\$DESTINATION environment variable cannot be empty empty"
|
||||||
#5: Error don't run operation
|
#5: Error don't run operation
|
||||||
exit 5
|
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
|
||||||
echo "dump file name:$TARGETFILENAME"
|
echo "dump file name:$TARGETFILENAME"
|
||||||
|
|
||||||
if [ -f /tmp/${TARGETFILENAME} ]
|
if [ -f /tmp/${TARGETFILENAME} ]
|
||||||
then
|
then
|
||||||
rm /tmp/${TARGETFILENAME}
|
rm /tmp/${TARGETFILENAME}
|
||||||
fi
|
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 "$DESTINATION" -prune -empty) = x"$DESTINATION" ]; 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 ${DESTINATION}/*
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mv /tmp/${TARGETFILENAME} ${DESTINATION}/${TARGETFILENAME}
|
mv /tmp/${TARGETFILENAME} ${DESTINATION}/${TARGETFILENAME}
|
||||||
|
|||||||
Reference in New Issue
Block a user