Skip to content

guiand888/borg-compact

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Borg Backup Compaction

standard-readme compliant

Automated Borg repository compaction with quota management and healthcheck integration

asciicast

Background

Automates compaction of Borg backup repositories running in Docker containers. Handles quota adjustments when repository size exceeds limits, integrates with UptimeKuma for monitoring, and includes dry-run capability for safe testing.

A typical use case is compact "append-only" repos managed with Borg Warehouse. Repose need to be compacted server-side and doing so by hand over a large number of a repos can be very cumbersome. The method used in this script will autonomously list:

  • list provisioned repos
  • work around quota discrepencies if any
  • compact repos
  • notify the admin of any success/failure through Uptime Kuma
  • does not require (manually or not) disabling "append-only mode" in Borg Warehouse

Quota Management Note: Borg Warehouse sets quotas via SSH command restrictions (borg serve --storage-quota), but borg compact enforces the repository's own storage_quota config. When actual usage exceeds this quota, the script temporarily expands it above current usage, runs compact, then restores the original quota.

Install

  1. Place borg_compact.sh in your target directory
  2. Make it executable: chmod +x borg_compact.sh
  3. For cron usage, you can consider using a cron-wrapper as needed: see guiand888/cron-wrapper

Usage

Environment Variables

Required:

export UPTIMEKUMA_DOMAIN=your-domain.com
export HEALTHCHECK_ID=your-healthcheck-id

Optional:

export CONTAINER_NAME=borgwarehouse-borgwarehouse-1
export REPO_DIR=/home/borgwarehouse/repos
export EXTRA_QUOTA_G=10
export VERBOSE=false

Run

# Normal execution
./borg_compact.sh

# Dry-run mode (lists repos and actions without making changes)
./borg_compact.sh --dry-run

# Force verbose output
VERBOSE=true ./borg_compact.sh

# Via cron
0 3 * * * /path/to/borg_compact.sh

Contributing

Pull requests accepted. For major changes, please open an issue first to discuss what you would like to change.

License

AGPLv3

About

Automated Borg repository compaction script with quota management and healthcheck integration

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages