How to Set Up Automated Backups
Hardware fails. Files get deleted. Ransomware exists. This guide shows you how to set up encrypted, automated, deduplicating backups with BorgBackup or Restic.
Why Automated Backups?
Backups are one of those "boring but critical" topics. Drives die. Laptops get stolen. Files get deleted by accident. Ransomware can lock you out of years of work in seconds. The only reliable defense is a backup that you do not have to remember to run.
The golden rule is the 3-2-1 rule:
- •3 copies of your data (the original plus two backups).
- •2 different storage media (internal drive plus external, or two different external drives).
- •1 copy stored offsite (cloud, a remote server, a friend's house).
BorgBackup and Restic both make this easy by providing encrypted, deduplicating repositories. Each backup only stores what changed since the last one, so snapshots are fast and small. Encryption means even if a remote server is compromised, your data stays private.
Step 1. Choose Your Tool
Both tools do essentially the same job -- encrypted, deduplicated, snapshot-based backups. Pick based on your platform and personal preference.
BorgBackup
- •Deduplicating, encrypted, compressed -- mature and battle-tested.
- •Great on Linux and macOS. Native builds work well.
- •Strong scriptable ecosystem (borgmatic, borgmatic, resticprofile equivalents).
- •Mountable archives via FUSE -- browse old snapshots like directories.
Restic
- •Cross-platform including native Windows support.
- •Simpler, more approachable command-line syntax.
- •Supports many backends natively: local, SFTP, S3, B2, Azure, Google Cloud.
- •Single static binary -- drop it on any system, no dependencies.
On Linux or Mac and like a mature community? Choose BorgBackup. On Windows or want a gentle learning curve? Choose Restic. This guide covers both, side by side, so you can follow whichever path suits you.
Step 2. Install
Installation is a single package on every major platform.
Linux (Debian / Ubuntu)
sudo apt install borgbackup
Or, for Restic:
sudo apt install restic
macOS (Homebrew)
brew install borgbackup
Or, for Restic:
brew install restic
Verify the install with borg --version or restic version.
Step 3. Initialize a Repository
The repository is the encrypted container that holds all your snapshots. Initialize it once on your backup destination -- an external drive, a network share, or a remote server.
BorgBackup
BORG_REPO=/path/to/backup borg init --encryption=repokey
You will be prompted to set a repository password. Save this password -- without it, the encrypted data is unrecoverable. The repokey mode stores the encrypted key inside the repository itself, convenient for most users.
Restic
restic init --repo /path/to/backup
Again, choose a strong password and store it in a password manager or environment variable so your automated job can use it.
Tip: Store the repo password in an environment variable (BORG_PASSPHRASE or RESTIC_PASSWORD) so cron jobs run non-interactively.
Step 4. Run Your First Backup
Now run a manual backup so you understand the syntax and the output. Substitute your own paths and snapshot names.
BorgBackup
borg create ::my-backup /home/user/Documents
This creates a snapshot named my-backup containing the contents of /home/user/Documents. The first backup takes longer because there is no deduplication baseline yet.
Restic
restic backup /home/user/Documents --repo /path/to/backup
Restic names snapshots by timestamp automatically. List them at any time with restic snapshots --repo /path/to/backup.
Confirm the snapshot by listing the repository contents. For Borg, run borg list ::. For Restic, run restic snapshots --repo /path/to/backup.
Step 5. Automate With Cron
A backup is only useful if it runs regularly. Add a cron entry to back up automatically at 2 AM every day.
BorgBackup Cron Entry
Open your crontab with crontab -e and add:
0 2 * * * BORG_REPO=/backup borg create ::{now}
For advanced users, consider borgmatic for a richer, YAML-configured wrapper that handles retention and notifications too.
Restic Cron Entry
0 2 * * * restic backup /home/user/Documents --repo /path/to/backup
Make sure the password is exported earlier in the cron environment, or set RESTIC_PASSWORD_FILE=/path/to/passfile.
Verification: The next morning, check /var/log/syslog or run borg list :: / restic snapshots to confirm a new snapshot appears nightly.
Step 6. Restore and Verify
An untested backup is a hope, not a backup. Restore a snapshot to a scratch directory and verify the files are intact before you trust the system.
BorgBackup Restore
borg extract ::my-backup
This extracts the snapshot into the current directory. List snapshots first with borg list :: to find the one you want.
To browse without extracting, mount the snapshot as a filesystem:
borg mount :: /mnt/borg
Navigate to /mnt/borg to browse every snapshot like directories. Unmount with borg umount /mnt/borg.
Restic Restore
restic restore latest --repo /path --target /restore
This restores the most recent snapshot into /restore. Replace latest with a snapshot ID from restic snapshots to restore an older point in time.
Quick Tips
- •Test restores regularly. A backup you never verify is a guess, not a guarantee.
- •Back up to remote repos via SSH. Borg supports user@host:/path syntax natively. Restic supports SFTP and many cloud backends.
- •Set retention policies. Use borg prune --keep-daily 7 --keep-weekly 4 --keep-monthly 12 or restic forget --keep-daily 7 --keep-weekly 4 to avoid unbounded repo growth.
- •Store the repo password in more than one secure location. Losing it means losing every backup.
- •Run borg check or restic check monthly to verify repository integrity.
- •Send yourself an email or notification when a backup fails. Silent failures are worse than no backups.
Need More Help?
Setting up encrypted automated backups is one of the most important security moves you can make -- and one of the easiest to get slightly wrong. Book a free call with StarCaller Academy and we will walk you through a setup tailored to your machine and routine.