This guide shows how to set up automated Borgmatic backups on Debian/Ubuntu, then sync the backup repository off‑site with rclone. You will install Borg, Borgmatic, and rclone, create a Borgmatic configuration, wire it into systemd, and verify that scheduled backups and uploads are working.
1. Install Borg, Borgmatic, and rclone
First install the tools from the Debian/Ubuntu repositories:
sudo apt update sudo apt install borgbackup borgmatic rclone -y This pulls in Borg (the backup engine), Borgmatic (the configuration and automation wrapper), and rclone (for syncing your Borg repo off‑site).
2. Create Borgmatic Config Directory
Create the system-wide Borgmatic configuration directory under /etc:
sudo mkdir -p /etc/borgmatic 3. Create and Edit Borgmatic Config
Create the main Borgmatic configuration file:
sudo nano /etc/borgmatic/config.yaml Start with a minimal example and adjust paths, repository, and rclone remote to match your setup:
location: source_directories: - /home - /etc repositories: - /mnt/backups/borg-repo storage: encryption_passphrase: "CHANGE_THIS_TO_A_STRONG_PASSPHRASE" retention: keep_daily: 7 keep_weekly: 4 keep_monthly: 6 hooks: post_backup: - /usr/bin/rclone sync /mnt/backups/borg-repo remote:borg-repo Update /mnt/backups/borg-repo to your actual Borg repository path and remote:borg-repo to your configured rclone remote.
4. Initialize the Borg Repository
If this is a new Borg repository, initialize it before running Borgmatic:
sudo borg init --encryption=repokey /mnt/backups/borg-repo Use the same passphrase here that you configured in config.yaml so Borgmatic can access the repo.
5. Test Borgmatic Manually
Before wiring everything into systemd, run Borgmatic once by hand to confirm that the configuration is valid:
sudo borgmatic --verbosity 1 --list This should create a new Borg archive and then run the post_backup rclone sync hook. Watch the output for errors.
6. Configure rclone Remote
If you have not already set up an rclone remote, run:
rclone config Follow the prompts to create a new remote (for example, Backblaze B2, S3, or another provider). Note the remote name you choose (such as remote) and update the post_backup hook in config.yaml to match it:
hooks: post_backup: - /usr/bin/rclone sync /mnt/backups/borg-repo remote:borg-repo 7. Create systemd Service and Timer
Next, wire Borgmatic into systemd so backups run automatically via a timer.
Create a systemd service unit for Borgmatic:
sudo nano /etc/systemd/system/borgmatic.service [Unit] Description=Run Borgmatic backup [Service] Type=oneshot Nice=10 IOSchedulingClass=best-effort IOSchedulingPriority=7 ExecStart=/usr/bin/borgmatic --verbosity 1 --list Then create a matching systemd timer to schedule the service:
sudo nano /etc/systemd/system/borgmatic.timer [Unit] Description=Run Borgmatic backup daily [Timer] OnCalendar=daily Persistent=true [Install] WantedBy=timers.target 8. Enable and Start the Timer
Reload systemd and enable the timer so it starts on boot and runs on schedule:
sudo systemctl daemon-reload sudo systemctl enable --now borgmatic.timer This activates the timer immediately and ensures it survives reboots.
9. Verify the Timer and Logs
Check that the timer is listed and scheduled:
systemctl list-timers | grep borgmatic Trigger a manual run of the service and watch the logs to confirm both Borgmatic and rclone are running correctly:
sudo systemctl start borgmatic.service journalctl -u borgmatic.service -f You should see Borgmatic create an archive and then the rclone sync command run. Once this works, you have automated, scheduled backups stored locally in a Borg repository and synced off‑site with rclone.