114 lines
2.2 KiB
Markdown
114 lines
2.2 KiB
Markdown
# Borgmatic Backup
|
|
|
|
Automated backup solution using [borgmatic](https://torsion.org/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`:
|
|
|
|
```bash
|
|
BORG_PASSPHRASE=your-strong-passphrase
|
|
```
|
|
|
|
2. Initialize the repository (first time only):
|
|
|
|
```bash
|
|
docker compose build borgmatic
|
|
|
|
docker compose run --rm borgmatic \
|
|
init --encryption repokey-blake2
|
|
```
|
|
|
|
## Usage
|
|
|
|
### Run Manual Backup
|
|
|
|
```bash
|
|
docker compose build borgmatic
|
|
|
|
docker compose run --rm borgmatic \
|
|
--stats -v 1
|
|
```
|
|
|
|
### Start Scheduled Backups
|
|
|
|
```bash
|
|
docker compose up -d
|
|
```
|
|
|
|
### List Archives
|
|
|
|
```bash
|
|
docker compose build borgmatic
|
|
|
|
docker compose run --rm borgmatic \
|
|
list
|
|
```
|
|
|
|
### Restore
|
|
|
|
```bash
|
|
# List files in an archive
|
|
docker compose run --rm borgmatic \
|
|
borg list ::archive-name
|
|
|
|
# Extract entire archive
|
|
docker compose run --rm borgmatic \
|
|
borg extract ::archive-name
|
|
|
|
# Extract specific path
|
|
docker compose run --rm borgmatic \
|
|
borg extract ::archive-name source/gitea_data
|
|
```
|
|
|
|
### Restore PostgreSQL Database
|
|
|
|
```bash
|
|
# Extract dump from backup
|
|
docker compose 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
|
|
|
|
```bash
|
|
docker compose build borgmatic
|
|
|
|
docker compose run --rm 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.
|