Files
selfhost-cloud-compose-stack/backup/borgmatic-README.md
2025-12-09 02:45:07 +03:30

2.3 KiB

Borgmatic Backup

Automated backup solution using borgmatic for Docker volumes and PostgreSQL databases with xattr preservation.

What Gets Backed Up

Named Volumes:

  • opencloud-config - OpenCloud configuration
  • opencloud-data - OpenCloud user data
  • gitea_data - Gitea repositories and data
  • odoo-db-data - Odoo filestore
  • odoo-config - Odoo configuration

PostgreSQL Databases:

  • giteadb - Gitea database
  • odoodb - Odoo database

Features

  • Preserves extended attributes (xattrs) and ACLs
  • Deduplication and zstd compression
  • Automated PostgreSQL dumps before each backup
  • Retention: 7 daily, 4 weekly, 6 monthly, 1 yearly
  • Scheduled daily at 3:00 AM

Setup

  1. Add to your .env:
BORG_PASSPHRASE=your-strong-passphrase
  1. Initialize the repository (first time only):
docker compose -f backup/borgmatic.yml run --rm borgmatic \
  borgmatic init --encryption repokey-blake2

Usage

Run Manual Backup

docker compose -f backup/borgmatic.yml run --rm borgmatic \
  borgmatic --stats -v 1

Start Scheduled Backups

docker compose -f backup/borgmatic.yml up -d

List Archives

docker compose -f backup/borgmatic.yml run --rm borgmatic \
  borgmatic list

Restore

# List files in an archive
docker compose -f backup/borgmatic.yml run --rm borgmatic \
  borg list ::archive-name

# Extract entire archive
docker compose -f backup/borgmatic.yml run --rm borgmatic \
  borg extract ::archive-name

# Extract specific path
docker compose -f backup/borgmatic.yml run --rm borgmatic \
  borg extract ::archive-name source/gitea_data

Restore PostgreSQL Database

# Extract dump from backup
docker compose -f backup/borgmatic.yml run --rm borgmatic \
  borg extract ::archive-name source/pgdumps/giteadb.dump

# Restore to database
docker exec -i postgres pg_restore -U admin -d giteadb -c /path/to/giteadb.dump

Check Repository

docker compose -f backup/borgmatic.yml run --rm borgmatic \
  borgmatic check

Configuration

  • backup/borgmatic.yml - Docker compose service
  • config/borgmatic/config.yaml - Borgmatic configuration
  • config/borgmatic/crontab.txt - Backup schedule

Security

⚠️ Keep BORG_PASSPHRASE safe - without it, backups cannot be restored.