Backfort

Your last line of data defense. Back up deliberately. Restore with
confidence.
Backfort is a recovery-first backup tool for Linux servers. It creates an
explicit, verified backup and exits—no daemon to babysit, no hidden discovery
of files or databases, and no risky in-place restore switch.
Get started ·
Install with Python ·
Run in Docker ·
Run in Kubernetes ·
Examples ·
Compose migration ·
Recovery guide ·
Security policy
Canonical repository: github.com/shellharbor/backfort
Pick your path
| I need to… |
Start here |
What Backfort gives you |
| Protect files and directories on a schedule |
First backup |
A strict YAML job for cron or a systemd timer. |
| Take a fast snapshot before a risky change |
Quick file backup |
A one-command backup plus a reusable non-secret recovery config. |
| Install the CLI with pip or pipx |
Python installation |
The canonical Bash engine, bundled with a dependency-free Python launcher. |
| Run Backfort as a containerized job |
Run in Docker |
The same YAML plan and recovery format, with explicit persistent mounts. |
| Protect files on Kubernetes PVCs |
Run in Kubernetes |
Helm Job/CronJob deployment with explicit read-only sources, durable state and isolated recovery. |
| Back up a Docker Compose stack |
Docker Compose sources |
Explicit project files, bind mounts, named volumes, and database dumps. |
| Move a Compose project to a new server |
Compose migration |
A staged runbook with rollback-minded cutover steps. |
| Restore a database to an isolated Compose project |
Compose restore assistant |
Verified staging and an explicit PostgreSQL/MySQL/MariaDB import boundary. |
| Send copies off-site |
Rclone destinations |
Local, S3-compatible, FTP, Dropbox, Yandex Disk, pCloud, and other rclone remotes. |
Why recovery stays predictable
explicit source → local bundle → checksum/signature → independent copies → .complete marker
↓
only then: list / verify / restore / prune
- No guessing. You name source paths, Compose files, volumes, bind mounts,
databases, destinations, and exclusions.
- No half-backup surprise. Payload, metadata, and checksum arrive before
the final
.complete marker. Interrupted uploads are never valid restores.
- No in-place roulette. Restore always requires a new or empty directory;
there is no
--force overwrite path.
- No secret values in YAML. Configuration refers to environment-variable
names, leaving passwords and keys with your secret manager or scheduler.
Backfort reads YAML, creates full backups, optionally compresses and encrypts
them, publishes each completed version atomically to one or more local or
rclone destinations, and exits. Scheduling belongs to cron, a systemd timer or a Kubernetes CronJob;
Backfort does not run a daemon.
Backfort 1.0.0 is the first stable release. It can archive explicit Compose
files, selected named volumes, explicit bind mounts and engine-aware database
dumps, then publish the resulting bundle through the same local and rclone
destinations as a file backup.
Features
- One Bash 4.3+ executable and one YAML configuration
- Optional Python 3.11+ launcher with pip/pipx packaging,
backfort and
python -m backfort entry points; no Python runtime dependencies
- Strict configuration validation with unknown-key detection
- Full-file and directory backups with GNU tar include roots and excludes
- Helm deployment for Kubernetes PVC-file backups, manual recovery Jobs and
suspended-by-default backup/prune CronJobs
- Docker Compose project snapshots: manifests, selected named volumes and bind
mounts
- Logical PostgreSQL, MySQL and MariaDB dumps; native MS SQL and Oracle export
artifacts
- A staged Compose recovery assistant with an explicit, double-confirmed
logical database import for PostgreSQL, MySQL and MariaDB
gzip, zstd, or uncompressed archives
- Optional multi-recipient
age or GPG encryption; GPG supports hardened
symmetric passwords and asymmetric public-key recipients
- Optional detached Minisign payload signatures for untrusted storage
- Multiple independent local or rclone destinations
- Offsite copies through rclone, including AWS S3, DigitalOcean Spaces, Vultr
Object Storage, Cloudflare R2, FTP/FTPS, Dropbox, Yandex Disk, pCloud and
other rclone-supported remotes
- Explicit
min_copies policy for a successful backup
- Durable local publication: data is synchronized before the final
.complete marker
- Fast payload checksum verification plus full per-file SHA-256 verification
- Safe restore into a new or empty directory
- Opt-in interactive restore version selection for a manual terminal session
- GFS-style
keep_last, daily, weekly, and monthly retention
- Per-destination pinned backups for migration and upgrade recovery points
- Safe opt-in
pre/post lifecycle hooks for application quiescing and cleanup
- Event notifications through Telegram, ntfy, webhooks, or local sendmail
- Global
flock for mutating commands
- Read-only dry-run mode and environment diagnostics
- Structured, journal-friendly log lines
Requirements
- Linux
- Bash 4.3 or newer
- Mike Farah yq v4
- GNU
tar, coreutils, findutils, util-linux, and gzip
- Optional:
zstd, age, GnuPG, Minisign, rclone, curl, msmtp, or sendmail when those features are enabled
- Docker Engine with the Compose v2 plugin for
docker_compose sources
- A pre-pulled, locally trusted helper image containing
tar for named-volume
snapshots; Backfort never pulls container images itself
On Debian or Ubuntu, the base packages can be installed with:
sudo apt-get install bash coreutils findutils gzip tar util-linux
Install Mike Farah yq v4 using its official release or package. The Python
package with the same name is not compatible.
Run Backfort through Python or install a PyPI package
The optional Python package bundles the same Bash engine and reference YAML.
It requires Python 3.11+ on Linux, plus the native Bash/GNU/yq prerequisites
above. It is not a Python rewrite or a Windows port; use Linux Python inside
WSL or the Docker image on Windows.
Python packaging was introduced in 1.3.0 without changing the native CLI
or backup format. Install the current 1.4.0 release into an isolated environment:
pipx install 'backfort==1.4.0'
pipx ensurepath
If pipx updated your PATH, open a new terminal before continuing. The package
installs the backfort command: you do not need a python prefix or a path
to backfort.sh.
backfort --version
backfort --help
backfort --print-example-config > backfort.example.yaml
Choose a new output filename: shell redirection overwrites existing files.
Edit the generated configuration's host ID, absolute source/destination paths,
encryption and retention before using it. Then check the setup, review a dry
run, and create the backup with the installed command:
backfort -c "$PWD/backfort.example.yaml" doctor
backfort -c "$PWD/backfort.example.yaml" --dry-run run
# Create the backup only after reviewing the configuration and dry run.
backfort -c "$PWD/backfort.example.yaml" run
Alternatively, use pip inside a virtual environment:
python3 -m venv .venv
.venv/bin/python -m pip install 'backfort==1.4.0'
.venv/bin/backfort --version
.venv/bin/python -m backfort --help
With a virtual environment, use .venv/bin/backfort instead of bare backfort
in the commands above, or activate it first with source .venv/bin/activate.
To install a trusted checkout instead, run .venv/bin/python -m pip install .
from its root directory. For privileged backups use a protected
installation; never run a user-writable virtual environment as root.
Direct execution from a checkout needs no Python package installation:
python3 run_backfort.py --version
python3 run_backfort.py -c /etc/backfort/config.yaml doctor
The launcher preserves arguments, environment, terminal, signals and engine
exit codes. It never downloads an engine or installs system tools. Native
Bash and Docker/Helm remain usable without Python. See
Python and PyPI for examples, tests, building and the
manual maintainer publishing procedure. Local build files are not evidence
that a package is already published.
Run Backfort in Docker
Backfort 1.4.0 uses a digest-pinned Debian trixie
runtime and POSIX mawk. GNU tar, GnuPG and SMTP support remain included.
The security verification report records the
complete vulnerability counts, remaining HIGH findings and exact release
verification status. The Compose example and Helm chart target 1.4.0.
The container image is an additional distribution method, not a second backup
engine. It runs the same backfort.sh, accepts the same strict YAML, and
creates the same portable bundles as a native installation. Images are
published for linux/amd64 and linux/arm64 to GitHub Container Registry:
docker pull ghcr.io/shellharbor/backfort:1.4.0
docker run --rm ghcr.io/shellharbor/backfort:1.4.0 --version
To pin the Docker Hub image to its verified multiarch release index:
docker pull shellharbor/backfort:1.4.0@sha256:123dcd108b6e7cb25ee30e2d199d52b4f19662e518508cf3372df5dd9c3a08b0
For a durable setup, copy the sample Compose file and its matching config into
a root-owned deployment directory. The example is deliberately a one-shot
job: it defaults to doctor and does not restart itself.
sudo install -d -m 0700 /srv/backfort-container
sudo cp docker-compose.example.yml /srv/backfort-container/docker-compose.yml
sudo cp examples/docker-files-local.yaml /srv/backfort-container/config.yaml
sudoedit /srv/backfort-container/config.yaml
export BACKFORT_SOURCE_DIR=/srv/application
export BACKFORT_BACKUP_DIR=/srv/backups/backfort
cd /srv/backfort-container
docker compose run --rm backfort doctor
docker compose run --rm backfort --dry-run run
docker compose run --rm backfort run
The image starts as root on purpose: a full staged restore may need to recreate
numeric ownership, ACLs, extended attributes, or sparse files. A files-only
job can set a non-root user: in the sample when the source, backup and
restore mounts are already writable by that account; doing so intentionally
trades away owner-preserving recovery. The example has a read-only container
root filesystem, but its named state and work volumes and the destination bind
mount remain writable. temp_directory needs room for a complete working
bundle, not merely a small scratch file.
The doctor exit status is the container's honest readiness result. Backfort
is not a daemon, so it intentionally has no HEALTHCHECK, no port, and no
restart: always. Schedule docker compose run --rm backfort run from the
host with cron or a systemd timer; schedule prune separately.
For docker_compose jobs, mount the Docker socket and the target project
directory at its same absolute host path inside Backfort (for example,
/srv/crm:/srv/crm:ro). A Docker socket is host-root-equivalent even when
mounted read-only. Use it only for a trusted Compose job and never for a
normal files-only backup. The complete deployment, secret, recovery and
upgrade guidance is in Docker deployment.
Release tags are immutable exact versions such as 1.4.0. Stable releases
also move 1.4, 1, and latest; pin an exact version or digest for a
repeatable run and retain the backfort-state volume during upgrades. Docker
Hub publication is optional and occurs only when the repository has both
DOCKERHUB_USERNAME and DOCKERHUB_TOKEN