Borgbackup

From David's Wiki
Revision as of 18:57, 30 December 2020 by David (talk | contribs) (→‎Extract)
\( \newcommand{\P}[]{\unicode{xB6}} \newcommand{\AA}[]{\unicode{x212B}} \newcommand{\empty}[]{\emptyset} \newcommand{\O}[]{\emptyset} \newcommand{\Alpha}[]{Α} \newcommand{\Beta}[]{Β} \newcommand{\Epsilon}[]{Ε} \newcommand{\Iota}[]{Ι} \newcommand{\Kappa}[]{Κ} \newcommand{\Rho}[]{Ρ} \newcommand{\Tau}[]{Τ} \newcommand{\Zeta}[]{Ζ} \newcommand{\Mu}[]{\unicode{x039C}} \newcommand{\Chi}[]{Χ} \newcommand{\Eta}[]{\unicode{x0397}} \newcommand{\Nu}[]{\unicode{x039D}} \newcommand{\Omicron}[]{\unicode{x039F}} \DeclareMathOperator{\sgn}{sgn} \def\oiint{\mathop{\vcenter{\mathchoice{\huge\unicode{x222F}\,}{\unicode{x222F}}{\unicode{x222F}}{\unicode{x222F}}}\,}\nolimits} \def\oiiint{\mathop{\vcenter{\mathchoice{\huge\unicode{x2230}\,}{\unicode{x2230}}{\unicode{x2230}}{\unicode{x2230}}}\,}\nolimits} \)

borgbackup is a deduplicating backup software

Installation

Installation

sudo apt install borgbackup

If you want the latest version, you can download a static build from releases or use this backport repo.

Usage

quickstart

Create a repo

borg init

# Create a repo without encryption
borg init --encryption=none ./testrepo
# If you want encryption
#borg init --encryption=repokey ./testrepo

Create a backup

borg create

The following will create a backup of ~/src titled Monday to the repo ./testrepo.

borg create --stats ./testrepo::Monday ~/src
Notes
  • Name placeholders: {now}, {utcnow}, {fqdn}, {hostname}, {user}
Examples
borg create \
  --stats --show-rc \
  ./testrepo::'{hostname}-daily-{utcnow}' \
  /src

Pruning backups

borg prune

If you're scripting daily, weekly, or monthly backups, you'll probably want to prune old backups.
The command below will keep one backup from today, one backup from last week, and one backup from one month.

borg prune --keep-daily 1 --keep-weekly 1 --keep-monthly 1 remote:~/my_backup

Extract

See extract

borg extract --progress <archive>
  • Note that borgbackup 1.1.11 included in Ubuntu 20.04 has a memory leak when using --progress documented here. Download a newer version of borgbackup.
  • You should extract to an empty folder since borg does not delete existing files in the target folder.

Resources