https://github.com/freaky/borg-backup.sh
A simple shell script for driving BorgBackup
https://github.com/freaky/borg-backup.sh
Last synced: 10 months ago
JSON representation
A simple shell script for driving BorgBackup
- Host: GitHub
- URL: https://github.com/freaky/borg-backup.sh
- Owner: Freaky
- License: mit
- Created: 2017-05-30T21:38:24.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2022-10-26T16:38:25.000Z (over 3 years ago)
- Last Synced: 2025-05-06T16:48:57.201Z (about 1 year ago)
- Language: Shell
- Size: 13.7 KB
- Stars: 22
- Watchers: 2
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# borg-backup.sh
A simple shell script for driving [Borg Backup][1].
## Usage
Make a borg-backup.conf from the provided template, e.g:
## Read from /etc/borg-backup.conf by default.
## Override by passing in CONFIG=/path/to.conf in the environment.
##
## This file is sourced by the shell.
###############################################################################
## Mandatory: Target destination for backups. Directory must exist.
##
TARGET=backup@fancy-backup-server:/backups/${HOSTNAME}
###############################################################################
## Mandatory: A passphrase to derive an encryption key from.
##
## Be wary of permissions on this file.
##
PASSPHRASE='ambiguous antelope capacitor paperclip'
###############################################################################
## Optional: Compression
##
## See 'borg help compression' for available options.
##
## This script defaults to zstd as of 0.7.0.
##
COMPRESSION='zstd'
###############################################################################
## Optional: Global prune configuration
##
PRUNE='-H 24 -d 14 -w 8 -m 6'
###############################################################################
## Optional: Compact threshold in percent
##
COMPACT_THRESHOLD='10'
###############################################################################
## Mandatory: Backup name list
##
BACKUPS='homes etc'
###############################################################################
## Mandatory: Backup configuration.
##
## One per backup name. Any borg create argument other than archive name is valid.
##
BACKUP_homes='/home/freaky -e /home/freaky/Maildir/mutt-cache'
BACKUP_etc='/etc /usr/local/etc'
###############################################################################
## Optional: Per-backup prune configuration.
##
## These override the global configuration for individual backups.
#
PRUNE_etc='--keep-hourly=72 --keep-daily=365'
This will produce two independent Borg archives. If using a remote host over SSH,
consider [locking down the public key][2], and using [append-only mode][3] to limit
the damage a compromised client can cause.
Initialize repositories:
$ borg-backup.sh init
And create your initial snapshots:
$ borg-backup.sh create
Any time you want to make a new backup, re-run the create command (ideally using cron or
other scheduler). Borg will create a new snapshot, adding only new data.
To list archives:
$ borg-backup.sh list
And to extract - in this case, `/etc/rc.conf` from the `etc` backup `etc-2017-02-21T20:00Z`:
$ borg-backup.sh extract etc ::etc-2017-02-21T20:00Z etc/rc.conf --stdout
To prune old backups:
$ borg-backup.sh prune
To recover space after one or more prune operations:
$ borg-backup.sh compact
To verify the repository and all archive metadata:
$ borg-backup.sh check
Or the repository and the last archive:
$ borg-backup.sh quickcheck
Or only the repository (a purely server-side check):
$ borg-backup.sh repocheck
For any Borg operation not covered explicitly, borg-backup.sh provides a `borg`
subcommand, which passes through the argument list to borg, having set up the
environment for the given repository. Refer to the [Borg documentation][4] for detailed
usage instructions.
## See Also
ZFS users may find [zfsnapr](https://github.com/Freaky/zfsnapr) of interest for creating
consistent point-in-time backups from snapshots.
## Alternatives
If you want something a bit fancier, [borgmatic][5] is worth a look.
[1]: https://borgbackup.readthedocs.io/
[2]: https://borgbackup.readthedocs.io/en/stable/deployment.html#restrictions
[3]: https://borgbackup.readthedocs.io/en/stable/usage.html#append-only-mode
[4]: https://borgbackup.readthedocs.io/en/stable/usage.html
[5]: https://github.com/witten/borgmatic