Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mr-ingenious/docker-backup-script
Simple Docker volumes backup script
https://github.com/mr-ingenious/docker-backup-script
backup docker script
Last synced: 15 days ago
JSON representation
Simple Docker volumes backup script
- Host: GitHub
- URL: https://github.com/mr-ingenious/docker-backup-script
- Owner: mr-ingenious
- License: gpl-3.0
- Created: 2024-04-21T12:16:01.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-04-22T17:55:25.000Z (7 months ago)
- Last Synced: 2024-04-22T19:15:03.213Z (7 months ago)
- Topics: backup, docker, script
- Language: Shell
- Homepage:
- Size: 20.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# docker-backup-script
Simple Docker volumes backup tool## Introduction
This script queries the available docker containers on a machine, stops them, creates backups of their volumes and starts the containers again.## Prerequisites
The script relies on ``jq``, ``gzip``, ``curl`` and ``tar``. It can send notifications to a Gotify server.## Usage
```
./backup_docker.sh [options]Usage examples:
./backup_docker.sh --help
./backup_docker.sh --template
./backup_docker.sh --backup /home/user/backup_config.jsonOptions:
-h, --help
print this help and exit-t, --template
print a backup config template structure with locally found docker containers-b config, --backup config
perform backup with configuration
```## Setting up everything
### Generating an initial configuration
An initial configuration can be automatically generated by invoking the script with the option ``-b ``. The configuration must be edited to specify* the backup base directory (output of the script containing the backup zips),
* the different storage directories (input for the script)
* additionally, the notification section that allows the script to report the results. Possible options are gotify and console output```
{
"created": "2024-04-21 14:35:02",
"backup_base_dir": "/home/user/docker/backups",
"backup_items": [
{
"name": "heimdall",
"id": "1153e2a7b0c6",
"image": "lscr.io/linuxserver/heimdall:latest",
"state": "running",
"storage_dir": "/home/user/docker/heimdall/volume"
},...
],
"notification": {
"type": "gotify",
"url": "http://my-gotify-server:88",
"token": "mytoken"
}
}
```INFORMATION: Please note that the script must be run as root as it calls docker for controlling the starting, stopping and querying the docker containers.
### Automatic task
The script can be placed anywhere in the file system. It can be invoked at given times / cycles with a cronjob, see example below.This configuration starts a backup every day at 01:00 o'clock:
```
0 1 * * * /bin/bash /home/user/scripts/backup_docker.sh -b /home/user/scripts/backup_config.json
```