production
This commit is contained in:
168
README.md
168
README.md
@@ -1,77 +1,91 @@
|
||||
# Duplicati
|
||||
|
||||
## Custom Docker Images
|
||||
|
||||
### Duplicati with mySql Client
|
||||
|
||||
[+ Information](docker/mysqlclient/README.md)
|
||||
|
||||
|
||||
## 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"
|
||||
```
|
||||
|
||||
|
||||
### Global Settings
|
||||
|
||||
```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
|
||||
|
||||
```
|
||||
|
||||
## Scripts
|
||||
|
||||
|
||||
### Environment Variables
|
||||
|
||||
_Source: https://github.com/duplicati/duplicati/blob/master/Duplicati/Library/Modules/Builtin/run-script-example.sh_
|
||||
|
||||
- DUPLICATI__EVENTNAME
|
||||
|
||||
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!
|
||||
|
||||
- DUPLICATI__OPERATIONNAME
|
||||
|
||||
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!
|
||||
|
||||
- DUPLICATI__RESULTFILE
|
||||
|
||||
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!
|
||||
|
||||
- DUPLICATI__REMOTEURL
|
||||
|
||||
This is the remote url for the target backend. This value can be changed by echoing --remoteurl = "new value".
|
||||
|
||||
- DUPLICATI__LOCALPATH
|
||||
|
||||
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__PARSED_RESULT
|
||||
|
||||
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
|
||||
# Duplicati
|
||||
|
||||
## Custom Docker Images
|
||||
|
||||
### Duplicati with mySql Client
|
||||
|
||||
[+ Information](docker/mysqlclient/README.md)
|
||||
|
||||
|
||||
## 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"
|
||||
```
|
||||
|
||||
|
||||
### Global Settings
|
||||
|
||||
```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
|
||||
|
||||
```
|
||||
## Scripts
|
||||
|
||||
### 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
|
||||
|
||||
_Source: https://github.com/duplicati/duplicati/blob/master/Duplicati/Library/Modules/Builtin/run-script-example.sh_
|
||||
|
||||
- DUPLICATI__EVENTNAME
|
||||
|
||||
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!
|
||||
|
||||
- DUPLICATI__OPERATIONNAME
|
||||
|
||||
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!
|
||||
|
||||
- DUPLICATI__RESULTFILE
|
||||
|
||||
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!
|
||||
|
||||
- DUPLICATI__REMOTEURL
|
||||
|
||||
This is the remote url for the target backend. This value can be changed by echoing --remoteurl = "new value".
|
||||
|
||||
- DUPLICATI__LOCALPATH
|
||||
|
||||
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__PARSED_RESULT
|
||||
|
||||
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
|
||||
|
||||
FROM duplicati/duplicati
|
||||
RUN apt update && apt install -y default-mysql-client && rm -rf /var/lib/apt/lists/*
|
||||
RUN mkdir duplicati-mysqlclient
|
||||
RUN mkdir duplicati-mysqlclient/scripts
|
||||
COPY /docker/mysqlclient/scripts/* /duplicati-mysqlclient/scripts/
|
||||
RUN chmod +x /duplicati-mysqlclient/scripts/*
|
||||
#check ../README.md for more information
|
||||
|
||||
FROM duplicati/duplicati
|
||||
RUN apt update && apt install -y default-mysql-client && rm -rf /var/lib/apt/lists/*
|
||||
RUN mkdir duplicati-mysqlclient
|
||||
RUN mkdir duplicati-mysqlclient/scripts
|
||||
COPY /docker/mysqlclient/scripts/* /duplicati-mysqlclient/scripts/
|
||||
RUN chmod +x /duplicati-mysqlclient/scripts/*
|
||||
EXPOSE 8200
|
||||
@@ -1,47 +1,60 @@
|
||||
# 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
|
||||
|
||||
```bash
|
||||
#Executed on repository root folder
|
||||
docker build -t duplicati-mysqlclient:latest -f docker/mysqlclient/Dockerfile .
|
||||
```
|
||||
|
||||
### 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:
|
||||
````
|
||||
# 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:
|
||||
````
|
||||
|
||||
@@ -1,49 +1,49 @@
|
||||
#!/bin/bash
|
||||
# mysql database backup.
|
||||
# executed by duplicati run-script-before-required
|
||||
# required environment variables:
|
||||
# DESTINATION
|
||||
# MYSQL_HOST
|
||||
# MYSQL_USER
|
||||
# MYSQL_PASSWORD
|
||||
# MYSQL_DATABASE
|
||||
|
||||
#any error must stop execution
|
||||
set -e
|
||||
|
||||
if [ $DUPLICATI__OPERATIONNAME == "Backup" ]
|
||||
then
|
||||
echo "Backup Job!!"
|
||||
else
|
||||
echo "Not a backup operation. exiting!"
|
||||
#OK, run operation
|
||||
exit
|
||||
fi
|
||||
|
||||
|
||||
if [ -z ${DESTINATION} ]
|
||||
then
|
||||
echo "\$DESTINATION environment variable cannot be empty empty"
|
||||
#5: Error don't run operation
|
||||
exit 5
|
||||
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 "$DESTINATION" -prune -empty) = x"$DESTINATION" ]; then
|
||||
echo "folder is empty... ignoring clean db dump folder"
|
||||
else
|
||||
rm -r ${DESTINATION}/*
|
||||
fi
|
||||
|
||||
mv /tmp/${TARGETFILENAME} ${DESTINATION}/${TARGETFILENAME}
|
||||
#!/bin/bash
|
||||
# mysql database backup.
|
||||
# executed by duplicati run-script-before-required
|
||||
# required environment variables:
|
||||
# DESTINATION
|
||||
# MYSQL_HOST
|
||||
# MYSQL_USER
|
||||
# MYSQL_PASSWORD
|
||||
# MYSQL_DATABASE
|
||||
|
||||
#any error must stop execution
|
||||
set -e
|
||||
|
||||
if [ $DUPLICATI__OPERATIONNAME == "Backup" ]
|
||||
then
|
||||
echo "Backup Job!!"
|
||||
else
|
||||
echo "Not a backup operation. exiting!"
|
||||
#OK, run operation
|
||||
exit
|
||||
fi
|
||||
|
||||
|
||||
if [ -z ${DESTINATION} ]
|
||||
then
|
||||
echo "\$DESTINATION environment variable cannot be empty empty"
|
||||
#5: Error don't run operation
|
||||
exit 5
|
||||
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 "$DESTINATION" -prune -empty) = x"$DESTINATION" ]; then
|
||||
echo "folder is empty... ignoring clean db dump folder"
|
||||
else
|
||||
rm -r ${DESTINATION}/*
|
||||
fi
|
||||
|
||||
mv /tmp/${TARGETFILENAME} ${DESTINATION}/${TARGETFILENAME}
|
||||
|
||||
Reference in New Issue
Block a user