1
Fork 0
mirror of https://github.com/Steffo99/backup-duplicity.git synced 2024-12-22 11:34:22 +00:00
gestalt-amadeus/README.md

112 lines
3.7 KiB
Markdown
Raw Normal View History

2024-06-05 07:09:23 +00:00
<div align="center">
2023-03-14 18:32:14 +00:00
2024-06-05 07:09:23 +00:00
![](.media/icon-128x128_round.png)
# Docker Duplicity Backup
Backup solution for Docker volumes based on Duplicity
</div>
2023-03-14 18:32:14 +00:00
## Usage
2023-06-27 17:32:50 +00:00
> **Warning**: This section is outdated. Update coming soon!
2023-03-14 18:32:14 +00:00
> **Note**: The following instructions assume Google Drive is used as a storage backend; refer to [duplicity's man page](https://duplicity.us/stable/duplicity.1.html) to find out how to configure different backends!
1. Create a new volume in Docker with the name `duplicity_credentials`:
2023-03-14 18:40:58 +00:00
```console
# docker volume create duplicity_credentials
```
2023-03-14 18:32:14 +00:00
2. Create a new file in the host system with the name `/root/secrets/backup/passphrase.txt`, and enter in it a secure passphrase to use to encrypt files:
2023-03-14 18:40:58 +00:00
```console
# echo 'CorrectHorseBatteryStaple' >> /root/secrets/backup/passphrase.txt
```
2023-03-14 18:32:14 +00:00
3. [Obtain *Desktop Application* OAuth credentials from the Google Cloud Console.](https://console.cloud.google.com/apis/credentials)
4. Create a new file in the host system with the name `/root/secrets/backup/client_config.yml`, and enter the following content in it:
2023-03-14 18:40:58 +00:00
```console
# edit /root/secrets/backup/client_config.yml
```
```yml
client_config_backend: settings
client_config:
client_id: "YOUR_GOOGLE_CLIENT_ID_GOES_HERE"
client_secret: "YOUR_GOOGLE_CLIENT_SECRET_GOES_HERE"
save_credentials: True
save_credentials_backend: file
save_credentials_file: "/var/lib/duplicity/credentials"
get_refresh_token: True
```
2023-03-14 18:32:14 +00:00
5. Add the following keys to the `docker-compose.yml` file of the project you want to backup:
2023-03-14 18:40:58 +00:00
```console
# edit ./docker-compose.yml
```
1. If you haven't already, upgrade your `docker-compose.yml` file to version 3.9:
```yml
version: "3.9"
```
2. Connect the previously created `duplicity_credentials` volume to the project:
```yml
volumes:
duplicity_credentials:
external: true
```
3. Setup the two previously created files as Docker secrets:
```yml
secrets:
duplicity_passphrase:
file: "/root/secrets/duplicity/passphrase.txt"
2023-03-14 18:40:58 +00:00
google_client_config:
file: "/root/secrets/duplicity/client_config.yml"
2023-03-14 18:40:58 +00:00
```
4. Add the following service:
```yml
services:
duplicity:
2023-03-14 18:40:58 +00:00
image: "ghcr.io/steffo99/backup-duplicity:latest"
restart: unless-stopped
secrets:
- google_client_config
- duplicity_passphrase
volumes:
- "duplicity_credentials:/var/lib/duplicity"
# Mount whatever you want to backup in subdirectories of /mnt
- ".:/mnt/compose" # Backup the current directory?
- "data:/mnt/data" # Backup a named volume?
environment:
MODE: "backup" # Change this to "restore" to restore the latest backup
DUPLICITY_TARGET_URL: "pydrive://YOUR_GOOGLE_CLIENT_ID_GOES_HERE/Duplicity/this" # Change this to the Drive directory you want to backup files to https://man.archlinux.org/man/duplicity.1.en#URL_FORMAT
# Don't touch these, they allow the program to read the secrets
DUPLICITY_PASSPHRASE_FILE: "/run/secrets/duplicity_passphrase"
GOOGLE_DRIVE_SETTINGS: "/run/secrets/google_client_config"
```
2023-03-14 18:32:14 +00:00
6. Log in to Google Drive and perform an initial backup with:
2023-03-14 18:40:58 +00:00
```console
2023-06-18 18:42:57 +00:00
# docker compose run -i --entrypoint=/bin/sh duplicity /etc/periodic/daily/backup.sh
2023-03-14 18:40:58 +00:00
```
2023-03-14 18:32:14 +00:00
7. Properly start the container with:
2023-03-14 18:40:58 +00:00
```console
# docker compose up -d && docker compose logs -f
2023-05-15 16:21:00 +00:00
```