### Install BorgBackup from Git Source: https://borgbackup.readthedocs.io/en/stable/installation.html Clone the repository, set up a virtual environment, install dependencies, and install BorgBackup in editable mode. Use `pip install -e .[pyfuse3]` or `pip install -e .[llfuse]` to include optional backends. ```bash # get borg from github git clone https://github.com/borgbackup/borg.git # create a virtual environment virtualenv --python=$(which python3) borg-env source borg-env/bin/activate # always before using! # install borg dependencies into virtualenv cd borg pip install -r requirements.d/development.txt pip install -r requirements.d/docs.txt # optional, to build the docs # set a borg version if setuptools-scm fails to do so automatically export SETUPTOOLS_SCM_PRETEND_VERSION= # install borg into virtualenv pip install -e . # in-place editable mode or pip install -e .[pyfuse3] # in-place editable mode, use pyfuse3 or pip install -e .[llfuse] # in-place editable mode, use llfuse # optional: run all the tests, on all installed Python versions # requires fakeroot, available through your package manager fakeroot -u tox --skip-missing-interpreters ``` -------------------------------- ### Setup Virtual Environment for PyPI Package Tests Source: https://borgbackup.readthedocs.io/en/stable/development.html Commands to create and activate a Python virtual environment. This is an optional step before installing packages for testing the BorgBackup PyPI distribution. ```bash # optional: create and use a virtual env: python3 -m venv env . env/bin/activate ``` -------------------------------- ### Install BorgBackup on openSUSE Source: https://borgbackup.readthedocs.io/en/stable/installation.html Use this command to install BorgBackup on openSUSE systems. ```bash zypper in borgbackup ``` -------------------------------- ### Install BorgBackup on FreeBSD Source: https://borgbackup.readthedocs.io/en/stable/installation.html Navigate to the ports directory and install BorgBackup on FreeBSD. ```bash cd /usr/ports/archivers/py-borgbackup && make install clean ``` -------------------------------- ### Install BorgBackup on NixOS Source: https://borgbackup.readthedocs.io/en/stable/installation.html Use this command to install BorgBackup on NixOS. ```bash nix-env -i borgbackup ``` -------------------------------- ### Install BorgBackup on OpenIndiana Source: https://borgbackup.readthedocs.io/en/stable/installation.html Use this command to install BorgBackup on OpenIndiana systems. ```bash pkg install borg ``` -------------------------------- ### Install Borg Backup and Setup Backup User with Salt Source: https://borgbackup.readthedocs.io/en/stable/deployment/central-backup-server.html This Salt configuration installs Borg backup from pip and sets up a dedicated backup user with a bash shell. Ensure all listed packages are installed before proceeding with pip installation. ```yaml Install borg backup from pip: pkg.installed: - pkgs: - python3 - python3-dev - python3-pip - python-virtualenv - libssl-dev - openssl - libacl1-dev - libacl1 - build-essential - libfuse-dev - fuse - pkg-config pip.installed: - pkgs: ["borgbackup"] - bin_env: /usr/bin/pip3 Setup backup user: user.present: - name: backup - fullname: Backup User - home: /home/backup - shell: /bin/bash ``` -------------------------------- ### Install BorgBackup on OpenBSD Source: https://borgbackup.readthedocs.io/en/stable/installation.html Use this command to install BorgBackup on OpenBSD systems. ```bash pkg_add borgbackup ``` -------------------------------- ### Install Borgbackup Dependencies on Cygwin Source: https://borgbackup.readthedocs.io/en/stable/installation.html Use the Cygwin installer to install required packages for Borgbackup. ```bash python39 python39-devel python39-setuptools python39-pip python39-wheel python39-virtualenv libssl-devel libxxhash-devel liblz4-devel libzstd-devel binutils gcc-g++ git make openssh ``` -------------------------------- ### Install BorgBackup on Fedora/RHEL Source: https://borgbackup.readthedocs.io/en/stable/installation.html Use this command to install BorgBackup on Fedora or RHEL systems using dnf. ```bash dnf install borgbackup ``` -------------------------------- ### Install Borg Man Pages Locally Source: https://borgbackup.readthedocs.io/en/stable/installation.html Clone the Borg repository from GitHub, install man pages with correct permissions, and update the man page cache. ```bash # get borg from github git clone https://github.com/borgbackup/borg.git borg # Install the files with proper permissions install -D -m 0644 borg/docs/man/borg*.1* $HOME/.local/share/man/man1/borg.1 # Update the man page cache mandb ``` -------------------------------- ### Install Borg Binary on Linux Source: https://borgbackup.readthedocs.io/en/stable/installation.html Copies the Borg binary to the system's PATH, sets ownership, and makes it executable. This is for standalone binary installations. ```bash sudo cp borg-linux /usr/local/bin/borg sudo chown root:root /usr/local/bin/borg sudo chmod 755 /usr/local/bin/borg ``` -------------------------------- ### Install BorgBackup on Gentoo Source: https://borgbackup.readthedocs.io/en/stable/installation.html Use this command to install BorgBackup on Gentoo Linux via the emerge package manager. ```bash emerge borgbackup ``` -------------------------------- ### Install BorgBackup on GNU Guix Source: https://borgbackup.readthedocs.io/en/stable/installation.html Use this command to install BorgBackup on GNU Guix systems. ```bash guix package --install borg ``` -------------------------------- ### Install BorgBackup on Mageia Source: https://borgbackup.readthedocs.io/en/stable/installation.html Use this command to install BorgBackup on Mageia Linux. ```bash urpmi borgbackup ``` -------------------------------- ### Install Pre-commit Hooks Source: https://borgbackup.readthedocs.io/en/stable/development.html Installs the pre-commit framework hooks. This ensures code is linted and formatted automatically before each commit. This command should be run after installing the development dependencies. ```bash pre-commit install ``` -------------------------------- ### Install BorgBackup on NetBSD Source: https://borgbackup.readthedocs.io/en/stable/installation.html Use this command to install BorgBackup on NetBSD systems using pkgsrc. ```bash pkg_add py-borgbackup ``` -------------------------------- ### Install Documentation Dependencies Source: https://borgbackup.readthedocs.io/en/stable/development.html Installs the necessary Python packages for building the documentation using Sphinx. ```shell pip install -r requirements.d/docs.txt ``` -------------------------------- ### Install BorgBackup on Debian/Ubuntu Source: https://borgbackup.readthedocs.io/en/stable/installation.html Use this command to install BorgBackup on Debian or Ubuntu systems using apt. ```bash apt install borgbackup ``` -------------------------------- ### Install BorgBackup with Pyenv Source: https://borgbackup.readthedocs.io/en/stable/installation.html Install a specific Python version using pyenv, set it globally and locally, create a virtual environment with that Python version, and activate it. ```bash # create a virtual environment pyenv install 3.10.0 # minimum, preferably use something more recent! pyenv global 3.10.0 pyenv local 3.10.0 virtualenv --python=${pyenv which python} borg-env source borg-env/bin/activate # always before using! ``` -------------------------------- ### Install Borgbackup Dependencies on openSUSE Source: https://borgbackup.readthedocs.io/en/stable/installation.html Use zypper to automatically install build dependencies for Borgbackup. Alternatively, list all dependencies manually. ```bash sudo zypper source-install --build-deps-only borgbackup ``` ```bash sudo zypper install python3 python3-devel libacl-devel openssl-devel libxxhash-devel python3-Cython python3-Sphinx python3-msgpack-python python3-pkgconfig pkgconf python3-pytest python3-setuptools python3-setuptools_scm python3-sphinx_rtd_theme gcc gcc-c++ sudo zypper install python3-llfuse # llfuse ``` -------------------------------- ### Create and Activate Virtual Environment for Borgbackup Source: https://borgbackup.readthedocs.io/en/stable/installation.html Create a virtual environment using virtualenv and activate it before installing Borgbackup. ```bash virtualenv --python=python3 borg-env source borg-env/bin/activate ``` -------------------------------- ### Install Borgbackup and FUSE Dependencies on FreeBSD Source: https://borgbackup.readthedocs.io/en/stable/installation.html Install necessary packages for Borgbackup and configure FUSE for mount command usage. ```bash pkg install -y python3 pkgconf pkg install openssl pkg install liblz4 zstd xxhash pkg install fusefs-libs # needed for llfuse pkg install -y git python3 -m ensurepip # to install pip for Python3 To use the mount command: echo 'fuse_load="YES"' >> /boot/loader.conf echo 'vfs.usermount=1' >> /etc/sysctl.conf kldload fuse sysctl vfs.usermount=1 ``` -------------------------------- ### Create a backup archive Source: https://borgbackup.readthedocs.io/en/stable/index.html Creates a backup archive from a specified directory. The example shows a basic creation command. ```bash $ borg create /path/to/repo::Saturday1 ~/Documents ``` -------------------------------- ### Initialize Borg Repository Source: https://borgbackup.readthedocs.io/en/stable/usage.html Run this command to initialize a new Borg repository before you can start creating archives. ```bash borg init ``` -------------------------------- ### Install BorgBackup on Alpine Linux Source: https://borgbackup.readthedocs.io/en/stable/installation.html Use this command to install BorgBackup on Alpine Linux via the apk package manager. ```bash apk add borgbackup ``` -------------------------------- ### BorgBackup Memory Usage Example (Default Chunker) Source: https://borgbackup.readthedocs.io/en/stable/internals/data-structures.html Example calculation of memory usage for backing up 1 Mi files totaling 1 TiB using default chunker parameters. ```plaintext > mem_usage = 0.31GiB ``` -------------------------------- ### Start Automated Backup Service Source: https://borgbackup.readthedocs.io/en/stable/deployment/automated-local.html Manually start the `automatic-backup` service to initiate the first backup. The `--no-block` flag allows the command to return immediately. ```bash systemctl start --no-block automatic-backup ``` -------------------------------- ### BorgBackup Pattern Configuration Example Source: https://borgbackup.readthedocs.io/en/stable/usage/help.html Defines recursion root, excludes, and includes for a backup. The first matching pattern determines inclusion or exclusion. ```bash # Define the recursion root R / # Exclude all iso files in any directory - **/*.iso # Explicitly include all inside etc and root + etc/** + root/** # Exclude a specific directory under each user's home directories - home/*/.cache # Explicitly include everything in /home + home/** # Explicitly exclude some directories without recursing into them ! re:(dev|proc|run|sys|tmp) # Exclude all other files and directories # that are not specifically included earlier. - ** ``` -------------------------------- ### Install Dependencies for PyPI Package Tests Source: https://borgbackup.readthedocs.io/en/stable/development.html Installs the borgbackup package and necessary testing tools (pytest, pytest-benchmark) using pip. This is required when running tests directly from the PyPI distribution. ```bash # install packages pip install borgbackup pip install pytest pytest-benchmark ``` -------------------------------- ### BorgBackup Memory Usage Example (Attic/Old Borg) Source: https://borgbackup.readthedocs.io/en/stable/internals/data-structures.html Example calculation of memory usage for backing up 1 Mi files totaling 1 TiB using older chunker parameters. ```plaintext > mem_usage = 2.8GiB ``` -------------------------------- ### Patterns File Example Source: https://borgbackup.readthedocs.io/en/stable/usage/help.html Defines backup patterns including excludes, includes, and specific file inclusions using shell-style patterns. ```bash # "sh:" pattern style is the default, so the following line is not needed: P sh R / # can be rebuild - home/*/.cache # they're downloads for a reason - home/*/Downloads # susan is a nice person # include susans home + home/susan # also back up this exact file + pf:home/bobby/specialfile.txt # don't backup the other home directories - home/* # don't even look in /proc ! proc ``` -------------------------------- ### Install/Upgrade Borgbackup using pip Source: https://borgbackup.readthedocs.io/en/stable/installation.html Install or upgrade Borgbackup and its dependencies within an activated virtual environment. Supports FUSE extras. ```bash # might be required if your tools are outdated pip install -U pip setuptools wheel # install Borg + Python dependencies into virtualenv pip install borgbackup # or alternatively (if you want FUSE support): pip install borgbackup[llfuse] # to use llfuse pip install borgbackup[pyfuse3] # to use pyfuse3 ``` ```bash pip install -U borgbackup # or ... borgbackup[llfuse/pyfuse3] ``` -------------------------------- ### Basic Compression Examples Source: https://borgbackup.readthedocs.io/en/stable/usage/help.html Demonstrates how to use different compression algorithms with `borg create`. Specify the desired compression method directly after the `--compression` flag. For algorithms like `zstd` and `zlib`, an optional compression level can be appended with a comma. ```bash borg create --compression lz4 REPO::ARCHIVE data ``` ```bash borg create --compression zstd REPO::ARCHIVE data ``` ```bash borg create --compression zstd,10 REPO::ARCHIVE data ``` ```bash borg create --compression zlib REPO::ARCHIVE data ``` ```bash borg create --compression zlib,1 REPO::ARCHIVE data ``` -------------------------------- ### Initialize Repository with Keyfile Encryption Source: https://borgbackup.readthedocs.io/en/stable/usage/key.html Example of initializing a new repository using keyfile encryption. This process prompts for a new passphrase and confirms it. ```bash # Create a key file protected repository $ borg init --encryption=keyfile -v /path/to/repo Initializing repository at "/path/to/repo" Enter new passphrase: Enter same passphrase again: Remember your passphrase. Your data will be inaccessible without it. Key in "/root/.config/borg/keys/mnt_backup" created. Keep this key safe. Your data will be inaccessible without it. Synchronizing chunks cache... Archives: 0, w/ cached Idx: 0, w/ outdated Idx: 0, w/o cached Idx: 0. Done. ``` -------------------------------- ### Initialize a new backup repository Source: https://borgbackup.readthedocs.io/en/stable/index.html Initializes a new backup repository. Use `borg init --help` for encryption options. ```bash $ borg init -e repokey /path/to/repo ``` -------------------------------- ### Ansible Playbook for Borg Server Setup Source: https://borgbackup.readthedocs.io/en/stable/deployment/central-backup-server.html This Ansible playbook configures the central backup server. It installs Borg, creates users and directories, and sets up authorized keys for specific client hosts with restricted commands. ```yaml - hosts: backup01.srv.local vars: user: backup group: backup home: /home/backup pool: "{{ home }}/repos" auth_users: - host: johndoe.clnt.local key: "{{ lookup('file', '/path/to/keys/johndoe.clnt.local.pub') }}" - host: web01.clnt.local key: "{{ lookup('file', '/path/to/keys/web01.clnt.local.pub') }}" - host: app01.clnt.local key: "{{ lookup('file', '/path/to/keys/app01.clnt.local.pub') }}" tasks: - package: name=borg state=present - group: name="{{ group }}" state=present - user: name="{{ user }}" shell=/bin/bash home="{{ home }}" createhome=yes group="{{ group }}" groups= state=present - file: path="{{ home }}" owner="{{ user }}" group="{{ group }}" mode=0700 state=directory - file: path="{{ home }}/.ssh" owner="{{ user }}" group="{{ group }}" mode=0700 state=directory - file: path="{{ pool }}" owner="{{ user }}" group="{{ group }}" mode=0700 state=directory - authorized_key: user="{{ user }}" key="{{ item.key }}" key_options='command="cd {{ pool }}/{{ item.host }};borg serve --restrict-to-path {{ pool }}/{{ item.host }}",restrict' with_items: "{{ auth_users }}" - file: path="{{ home }}/.ssh/authorized_keys" owner="{{ user }}" group="{{ group }}" mode=0600 state=file - file: path="{{ pool }}/{{ item.host }}" owner="{{ user }}" group="{{ group }}" mode=0700 state=directory with_items: "{{ auth_users }}" ``` -------------------------------- ### Simple Archive Listing with borg list --json Source: https://borgbackup.readthedocs.io/en/stable/internals/frontends.html Example JSON output from 'borg list --last 1 --json', showing basic archive information such as ID, name, and start time. ```json { "archives": [ { "id": "80cd07219ad725b3c5f665c1dcf119435c4dee1647a560ecac30f8d40221a46a", "name": "host-system-backup-2017-02-27", "start": "2017-08-07T12:27:20.789123" } ], "encryption": { "mode": "repokey" }, "repository": { "id": "0cbe6166b46627fd26b97f8831e2ca97584280a46714ef84d2b668daf8271a23", "last_modified": "2017-08-07T12:27:20.789123", "location": "/home/user/repository" } } ``` -------------------------------- ### Install Borgbackup Dependencies from Git Repo on macOS Source: https://borgbackup.readthedocs.io/en/stable/installation.html Install Python 3.11 and bundle dependencies from the Borg repository's Brewfile, then install virtualenv. ```bash brew install python@3.11 # can be any supported python3 version brew bundle install # install requirements from borg repo's ./Brewfile pip3 install virtualenv ``` -------------------------------- ### Mount and unmount using borgfs via /etc/fstab Source: https://borgbackup.readthedocs.io/en/stable/usage/mount.html This example shows how to configure and use 'borgfs' for mounting and unmounting archives by adding entries to '/etc/fstab'. It demonstrates mounting both a full repository and a specific archive. ```bash $ echo '/mnt/backup /tmp/myrepo fuse.borgfs defaults,noauto 0 0' >> /etc/fstab $ echo '/mnt/backup::root-2016-02-15 /tmp/myarchive fuse.borgfs defaults,noauto 0 0' >> /etc/fstab $ mount /tmp/myrepo $ mount /tmp/myarchive $ ls /tmp/myrepo root-2016-02-01 root-2016-02-15 $ ls /tmp/myarchive bin boot etc home lib lib64 lost+found media mnt opt root sbin srv tmp usr var ``` -------------------------------- ### Initialize Borg Repository (Basic) Source: https://borgbackup.readthedocs.io/en/stable/deployment/central-backup-server.html Use this command on the client to initialize a new Borg repository on the central server using a relative path. ```bash borg init ssh://backup@backup01.srv.local/./pictures ``` -------------------------------- ### Install Borgbackup with FUSE support on macOS using pip Source: https://borgbackup.readthedocs.io/en/stable/installation.html When installing Borg via pip, install the 'llfuse' extra and set PKG_CONFIG_PATH for openssl. ```bash PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig" pip install borgbackup[llfuse] ``` -------------------------------- ### Initialize Borg Repository (Full Path) Source: https://borgbackup.readthedocs.io/en/stable/deployment/central-backup-server.html Initialize a Borg repository using a full, absolute path on the server. This is primarily for demonstration and should not be the typical usage. ```bash borg init ssh://backup@backup01.srv.local/home/backup/repos/johndoe.clnt.local/pictures ``` -------------------------------- ### Initialize Borg Repository Source: https://borgbackup.readthedocs.io/en/stable/deployment/automated-local.html Initialize a new Borg repository on a mounted backup drive. Ensure the drive is mounted at `/mnt/backup` before running. ```bash borg init --encryption ... /mnt/backup/borg-backups/backup.borg ``` -------------------------------- ### Build, Sign, and Upload Release Packages Source: https://borgbackup.readthedocs.io/en/stable/development.html Commands to create a source distribution (sdist), sign it, and upload it to PyPI. Use 'test' as the second argument for test PyPI. ```shell scripts/sdist-sign X.Y.Z scripts/upload-pypi X.Y.Z test scripts/upload-pypi X.Y.Z ``` -------------------------------- ### Initialize Local Repository with Repokey Encryption Source: https://borgbackup.readthedocs.io/en/stable/usage/init.html Use this command to initialize a local repository with repokey encryption and BLAKE2b hashing. BLAKE2b is often faster than older hashing algorithms since Borg 1.1. ```bash $ borg init --encryption=repokey-blake2 /path/to/repo ``` -------------------------------- ### Install macFUSE on macOS Source: https://borgbackup.readthedocs.io/en/stable/installation.html Install macFUSE using Homebrew for FUSE support to mount backup archives. ```bash brew install --cask macfuse ``` -------------------------------- ### List repository configuration Source: https://borgbackup.readthedocs.io/en/stable/usage/config.html Use the `--list` option to display the current configuration of the repository. ```bash borg config --list /path/to/repo ``` -------------------------------- ### Initialize Borg Repository Source: https://borgbackup.readthedocs.io/en/stable/quickstart.html Initialize a new Borg repository with repository key encryption. This is the first step before creating any backups. ```bash $ borg init --encryption=repokey /path/to/repo ``` -------------------------------- ### Install BorgBackup on macOS Source: https://borgbackup.readthedocs.io/en/stable/installation.html Install BorgBackup on macOS using Homebrew. Note the different commands for FUSE support. ```bash brew install borgbackup ``` ```bash brew install --cask macfuse ``` ```bash brew install borgbackup/tap/borgbackup-fuse ``` -------------------------------- ### Install BorgBackup on Arch Linux Source: https://borgbackup.readthedocs.io/en/stable/installation.html Use this command to install BorgBackup on Arch Linux via the pacman package manager. ```bash pacman -S borg ``` -------------------------------- ### Create Archives for Diff Comparison Source: https://borgbackup.readthedocs.io/en/stable/usage/diff.html Initial setup to create archives that will be used for diff operations. This involves initializing a repository and creating multiple archives with modifications. ```bash $ borg init -e=none testrepo $ mkdir testdir $ cd testdir $ echo asdf > file1 $ dd if=/dev/urandom bs=1M count=4 > file2 $ touch file3 $ borg create ../testrepo::archive1 . $ chmod a+x file1 $ echo "something" >> file2 $ borg create ../testrepo::archive2 . $ echo "testing 123" >> file1 $ rm file3 $ touch file4 $ borg create ../testrepo::archive3 . $ cd .. ``` -------------------------------- ### Run All BorgBackup Tests with Tox Source: https://borgbackup.readthedocs.io/en/stable/development.html Execute the full test suite using tox. Requires fakeroot and tox to be installed. Omit `fakeroot -u` if fakeroot is not available. ```bash fakeroot -u tox # run all tests ``` -------------------------------- ### Install Development Dependencies Source: https://borgbackup.readthedocs.io/en/stable/development.html Installs all necessary Python packages for development and testing using pip. Ensure your virtual environment is activated before running this command. ```bash pip install -r requirements.d/development.txt ``` -------------------------------- ### Example GPG Verification Output Source: https://borgbackup.readthedocs.io/en/stable/support.html This is an example of the expected output from GPG when a signature is successfully verified. It confirms the signature's validity and the key used. ```text gpg: Signature made Sat 30 Dec 2017 01:07:36 PM CET using RSA key ID 51F78E01 gpg: Good signature from "Thomas Waldmann " gpg: aka "Thomas Waldmann " gpg: aka "Thomas Waldmann " gpg: aka "Thomas Waldmann " gpg: WARNING: This key is not certified with a trusted signature! gpg: There is no indication that the signature belongs to the owner. Primary key fingerprint: 6D5B EF9A DD20 7580 5747 B70F 9F88 FB52 FAF7 B393 Subkey fingerprint: 2F81 AFFB AB04 E11F E8EE 65D4 243A CFA9 51F7 8E01 ``` -------------------------------- ### Auto and Obfuscate Compression Examples Source: https://borgbackup.readthedocs.io/en/stable/usage/help.html Shows how to use the `auto` compression heuristic, which decides per chunk whether to compress, and the `obfuscate` option for size obfuscation. `auto` can be combined with a specific compression method and level. `obfuscate` requires a SPEC value and a compression method, and must be combined with encryption. ```bash borg create --compression auto,lzma,6 REPO::ARCHIVE data ``` ```bash borg create --compression auto,lzma ... ``` ```bash borg create --compression obfuscate,110,none ... ``` ```bash borg create --compression obfuscate,3,auto,zstd,10 ... ``` ```bash borg create --compression obfuscate,2,zstd,6 ... ``` ```bash borg create --compression obfuscate,250,zstd,3 ... ```