script tidyups

This commit is contained in:
2026-04-20 14:12:35 +12:00
parent a94d723bdf
commit 5c7f9b0c9d
3 changed files with 213 additions and 106 deletions
+66 -3
View File
@@ -9,9 +9,72 @@ Simple shell scripts for backing up Docker-related data and pruning old backups.
- `containers.txt` - list of containers or backup targets
- `.env.example` - example environment file
## Setup
## Reqirements
Copy the example env file and edit it for your system:
docker-compose
```bash
## BACKUPS: Example use docker-backup.sh
Configure the backup script, docker-backup.sh
Set up your list of containers in container.txt . The script assumes each container is in a subdirectory of one main docker directory
Edit the location of where you want docker backups stored in docker-backup.sh (default is "/dockerbackups") or use
./docker-backup.sh -s /home/me/mycontainers
It will recurse though the directories if they are listed in containers.txt .
It will run docker-compose to take down the container, pull a new version if there is one, then bring the container back up.
Then it will create a timestamped arcive of each container in the backup directory, under a directory with that container name.
Usage: ./docker-backup.sh [-f containers_list_file] [-s source_base_dir] [-t] [-v] [-h]
Flags:
-t Test (dry run; no backups performed)
-v Verbose (debug logging to stderr)
-f FILE File containing list of container names
Default: '$containersfile'
-s DIR Base directory containing container/project folders
Default: '$SOURCE_BASE_DIR'
-h Show this help
## PRUNE and REMOTE BACKUP dockerbackup_prune.sh
Set up the env file using the example.
cp .env.example .env
You don't need to worry about the rclone info (backups to google drive) it you won't be using that.
It will just backup up the file locally. Feel free to adjust for other remote backup systems.
If you run .dockerbackup_prune.sh it will prune the number of backup archives that are already there (based on your prune numbers), make a .zst archive of all container backups
then finally uploades to google drive and deletes the large archive (if that's what you set).
Then it will prune the number of archive files for each
# local archive only (no pruning)
./dockerbackup_prune.sh
# local archive + real prune, keep new archive locally. Default prune is 5 archives)
./dockerbackup_prune.sh --apply
# local archive + upload + prune dry-run (no actual prune), keep new archive locally (default location is /tmp)
./dockerbackup_prune.sh --rclone
# full remote archive, google drive upload + real prune (default 5) + delete new local archive
./dockerbackup_prune.sh --rclone --apply
# Full remote workflow with actual prune leaving 3 archives of each container and final full archive delete.
# Specify location of docker archives, final archive dir and remote google drive folder.
./dockerbackup_prune.sh --root /mydockerarchives --/mybigbackupdolder --keep 3 --rclone /dockergooglebackup --apply
Usage: $0 [--apply] [--quiet] [--dry-run] [--keep N] [--root PATH] [--source PATH] [--outdir PATH] [--remote PATH]
Flags:
--rclone Enable rclone upload flow
--apply Actually delete pruned files; with --rclone also delete the new local archive
--quiet Minimal console output (no live progress)
--dry-run Simulate everything (no backup, no upload, no deletes)
--keep N Keep newest N .zst files per subfolder (default ${KEEP_COUNT})
--root PATH Root folder to prune (default ${PRUNE_ROOT})
--source PATH Folder to archive (default ${SOURCE_DIR})
--outdir PATH Where to write the .zst (default ${OUT_DIR})
--remote PATH rclone destination (default ${RCLONE_REMOTE})