peetvandesande/file-backup

By peetvandesande

•Updated 7 months ago

File-based backup container

Image
Security
Web servers
Databases & storage
0

1.6K

peetvandesande/file-backup repository overview

ā šŸ—‚ļø file-backup

Docker Pulls Image Size GitHub License

Lightweight backup container that creates timestamped tar archives.

No rotation, pruning, encryption, or cloud upload logic is included — bring your own retention policy.


ā šŸš€ Quick Usage

⁠One-off backup
docker run --rm \
  -v /var/backups:/backups \
  -v /var/www/html:/data:ro \
  -e BACKUP_NAME_PREFIX=web-data \
  -e BACKUP_PATHS="/data" \
  -e RUN_ONCE=1 \
  peetvandesande/file-backup:alpine
⁠Scheduled backup ( daily at 02:30 by default )
docker run -d --name web-backup \
  -v /var/backups:/backups \
  -v /var/www/html:/data:ro \
  -e BACKUP_NAME_PREFIX=web-data \
  -e BACKUP_PATHS="/data" \
  peetvandesande/file-backup:alpine

Override schedule:

-v ./crontab:/etc/crontabs/root:ro

To run a backup before cron starts:

-e RUN_BACKUP_ON_START=1

⁠🧰 Restore

Restore the latest matching archive:

docker run --rm \
  -v /var/backups:/backups \
  -v /var/www/html:/restore \
  peetvandesande/file-backup:alpine restore /restore

Restore a specific archive:

docker run --rm \
  -v /var/backups:/backups \
  -v /var/www/html:/restore \
  peetvandesande/file-backup:alpine restore /backups/web-data-20251106.tar.gz /restore

If you want predictable chmod/chown after extraction, restore into a fresh directory and then adjust ownership afterwards.


ā āš™ļø Environment Variables

VariableDefaultDescription
BACKUP_NAME_PREFIXrequiredPrefix for archive filenames
BACKUP_PATHSrequiredSpace-separated list of paths to include
BACKUPS_DIR/backupsWhere archives are stored
COMPRESSgzgz, bz2, zst, or none
COMPRESS_LEVEL(auto)Optional compression level
VERIFY_SHA25611 = write .sha256 file
PRESERVE_TIMES11 = keep mtimes, 0 = normalize
CHOWN_UID(unset)Apply user ownership (if set)
CHOWN_GID(unset)Apply group ownership (if set)
CHMOD_MODE(unset)Apply mode to archive/sha file e.g. 0640
EXCLUDE_PATTERNS(unset)Space-separated patterns → tar --exclude=
RUN_ONCE0Run backup once and exit
RUN_BACKUP_ON_START0Run backup before cron starts
⁠Ownership Logic Example
# Force UID=34, keep existing GID:
-e CHOWN_UID=34

# Force GID=34, keep existing UID:
-e CHOWN_GID=34

# Force both explicitly:
-e CHOWN_UID=34 -e CHOWN_GID=34

ā šŸ“¦ Output Format

/backups/
ā”œā”€ā”€ web-data-20251106.tar.gz
└── web-data-20251106.tar.gz.sha256

ā šŸ·ļø Tags

TagDescription
alpine (default)Smallest runtime image
devWork-in-progress branch images
<version>Tagged stable releases

⁠🐳 Docker Compose Example

services:
  web:
    image: "httpd"
    volumes:
      - www-data:/var/www

  app-backup:
    image: peetvandesande/file-backup
    environment:
      - BACKUP_NAME_PREFIX=web-data
      - BACKUP_PATHS="/var/www/html /local"
      - COMPRESS=bz2
      - CHOWN_UID=34
      - CHOWN_GID=34
      - CHMOD_MODE=0640
    volumes:
      - ./docker-compose.yml:/local/docker-compose.yml
      - www-data:/var/www:ro
      - /var/backups:/backups

volumes:
  www-data: {}    
    

This setup runs a Apache HTTPD container and a backup container side by side with backups stored under ./backups on the host. It also takes a copy of docker-compose.yml for easy restoration of the full application.


Full docs and Nextcloud guide available here:
→ https://github.com/peetvandesande/file-backup/tree/main/docs/⁠

Tag summary

Content type

Image

Digest

sha256:8ef193421…

Size

6.4 MB

Last updated

7 months ago

docker pull peetvandesande/file-backup:v2.0.1-alpine