Installation
************

There are different ways to install Borg:

* Distribution Package - easy and fast if a package is available from
  your distribution.

* Standalone Binary - easy and fast, we provide a ready-to-use binary
  file that comes bundled with all dependencies.

* From Source, either:

  * Using pip - installing a source package with pip needs more
    installation steps and requires all dependencies with development
    headers and a compiler.

  * Using git  - for developers and power users who want to have the
    latest code or use revision control (each release is tagged).


Distribution Package
====================

Some distributions might offer a ready-to-use "borgbackup" package
which can be installed with the package manager.

Important:

  Those packages may not be up to date with the latest Borg releases.
  Before submitting a bug report, check the package version and
  compare that to our latest release then review Important notes to
  see if the bug has been fixed. Report bugs to the package maintainer
  rather than directly to Borg if the package is out of date in the
  distribution.

+--------------+-----------------------------------------------+-----------------------------------------------------------------------+
| Distribution | Source                                        | Command                                                               |
|==============|===============================================|=======================================================================|
| Alpine Linux | Alpine repository                             | "apk add borgbackup"                                                  |
+--------------+-----------------------------------------------+-----------------------------------------------------------------------+
| Arch Linux   | [extra]                                       | "pacman -S borg"                                                      |
+--------------+-----------------------------------------------+-----------------------------------------------------------------------+
| Debian       | Debian packages                               | "apt install borgbackup"                                              |
+--------------+-----------------------------------------------+-----------------------------------------------------------------------+
| Gentoo       | ebuild                                        | "emerge borgbackup"                                                   |
+--------------+-----------------------------------------------+-----------------------------------------------------------------------+
| GNU Guix     | GNU Guix                                      | "guix package --install borg"                                         |
+--------------+-----------------------------------------------+-----------------------------------------------------------------------+
| Fedora/RHEL  | Fedora official repository                    | "dnf install borgbackup"                                              |
+--------------+-----------------------------------------------+-----------------------------------------------------------------------+
| FreeBSD      | FreeBSD ports                                 | "cd /usr/ports/archivers/py-borgbackup && make install clean"         |
+--------------+-----------------------------------------------+-----------------------------------------------------------------------+
| macOS        | Homebrew                                      | "brew install borgbackup" (official formula, **no** FUSE support)     |
|              |                                               | **or** "brew install --cask macfuse" (private Tap, FUSE support)      |
|              |                                               | "brew install borgbackup/tap/borgbackup-fuse"                         |
+--------------+-----------------------------------------------+-----------------------------------------------------------------------+
| Mageia       | cauldron                                      | "urpmi borgbackup"                                                    |
+--------------+-----------------------------------------------+-----------------------------------------------------------------------+
| NetBSD       | pkgsrc                                        | "pkg_add py-borgbackup"                                               |
+--------------+-----------------------------------------------+-----------------------------------------------------------------------+
| NixOS        | .nix file                                     | "nix-env -i borgbackup"                                               |
+--------------+-----------------------------------------------+-----------------------------------------------------------------------+
| OpenBSD      | OpenBSD ports                                 | "pkg_add borgbackup"                                                  |
+--------------+-----------------------------------------------+-----------------------------------------------------------------------+
| OpenIndiana  | OpenIndiana hipster repository                | "pkg install borg"                                                    |
+--------------+-----------------------------------------------+-----------------------------------------------------------------------+
| openSUSE     | openSUSE official repository                  | "zypper in borgbackup"                                                |
+--------------+-----------------------------------------------+-----------------------------------------------------------------------+
| Raspbian     | Raspbian testing                              | "apt install borgbackup"                                              |
+--------------+-----------------------------------------------+-----------------------------------------------------------------------+
| Ubuntu       | Ubuntu packages, Ubuntu PPA                   | "apt install borgbackup"                                              |
+--------------+-----------------------------------------------+-----------------------------------------------------------------------+

Please ask package maintainers to build a package or, if you can
package / submit it yourself, please help us with that! See #105 on
github to followup on packaging efforts.

**Current status of package in the repositories**

[image: Packaging status][image]


Standalone Binary
=================

Note:

  Releases are signed with an OpenPGP key, see Security for more
  instructions.

Borg x86-64 AMD/Intel-compatible binaries (generated with pyinstaller)
are available on the releases page for the following platforms (for
more details see the "00_README.txt" file there):

* Linux

* FreeBSD

* MacOS

ARM binaries are built by Johann Bauer, see: https://borg.bauerj.eu/

To install such a binary, just drop it into a directory in your
"PATH", make borg readable and executable for its users and then you
can run "borg":

   sudo cp borg-linux /usr/local/bin/borg
   sudo chown root:root /usr/local/bin/borg
   sudo chmod 755 /usr/local/bin/borg

Optionally you can create a symlink to have "borgfs" available, which
is an alias for "borg mount":

   ln -s /usr/local/bin/borg /usr/local/bin/borgfs

Note that the binary uses /tmp to unpack Borg with all dependencies.
It will fail if /tmp has not enough free space or is mounted with the
"noexec" option. You can change the temporary directory by setting the
"TEMP" environment variable before running Borg.

If a new version is released, you will have to manually download it
and replace the old version using the same steps as shown above.


From Source
===========

Note:

  Some older Linux systems (like RHEL/CentOS 5) and Python interpreter
  binaries compiled to be able to run on such systems (like Python
  installed via Anaconda) might miss functions required by Borg.This
  issue will be detected early and Borg will abort with a fatal error.


Dependencies
------------

To install Borg from a source package (including pip), you have to
install the following dependencies first. For the libraries you will
also need their development header files (sometimes in a separate
*-dev* or *-devel* package).

* Python 3 >= 3.10.0

* OpenSSL >= 1.0.0

* libacl (which depends on libattr)

* libxxhash >= 0.8.1

* liblz4 >= 1.7.0 (r129)

* libzstd >= 1.3.0

* pkg-config (cli tool) - Borg uses this to discover header and
  library locations automatically. Alternatively, you can also point
  to them via some environment variables, see setup.py.

* Some other Python dependencies, pip will automatically install them
  for you.

* Optionally, if you wish to mount an archive as a FUSE filesystem,
  you need a FUSE implementation for Python:

  * pyfuse3 >= 3.1.1 (for fuse 3, use *pip install
    borgbackup[pyfuse3]*), or

  * llfuse >= 1.3.8 (for fuse 2, use *pip install
    borgbackup[llfuse]*).

  * Additionally, your OS will need to have FUSE support installed
    (e.g. a package *fuse* for fuse 2 or a package *fuse3* for fuse 3
    support).

If you have troubles finding the right package names, have a look at
the distribution specific sections below or the Vagrantfile in the git
repository, which contains installation scripts for a number of
operating systems.

In the following, the steps needed to install the dependencies are
listed for a selection of platforms. If your distribution is not
covered by these instructions, try to use your package manager to
install the dependencies.

After you have installed the dependencies, you can proceed with steps
outlined under Using pip.


Arch Linux
~~~~~~~~~~

Install the runtime and build dependencies:

   pacman -S python python-pip python-virtualenv openssl acl xxhash lz4 zstd base-devel
   pacman -S fuse2     # needed for llfuse
   pacman -S fuse3     # needed for pyfuse3

Note that Arch Linux specifically doesn't support partial upgrades, so
in case some packages cannot be retrieved from the repo, run with
"pacman -Syu".


Debian / Ubuntu
~~~~~~~~~~~~~~~

Install the dependencies with development headers:

   sudo apt-get install python3 python3-dev python3-pip python3-virtualenv \
   libacl1-dev \
   libssl-dev \
   liblz4-dev libzstd-dev libxxhash-dev \
   build-essential pkg-config
   sudo apt-get install libfuse-dev fuse    # needed for llfuse
   sudo apt-get install libfuse3-dev fuse3  # needed for pyfuse3

In case you get complaints about permission denied on
"/etc/fuse.conf": on Ubuntu this means your user is not in the "fuse"
group. Add yourself to that group, log out and log in again.


Fedora
~~~~~~

Install the dependencies with development headers:

   sudo dnf install python3 python3-devel python3-pip python3-virtualenv \
   libacl-devel \
   openssl-devel \
   lz4-devel libzstd-devel xxhash-devel \
   pkgconf
   sudo dnf install gcc gcc-c++ redhat-rpm-config
   sudo dnf install fuse-devel fuse         # needed for llfuse
   sudo dnf install fuse3-devel fuse3       # needed for pyfuse3


openSUSE Tumbleweed / Leap
~~~~~~~~~~~~~~~~~~~~~~~~~~

Install the dependencies automatically using zypper:

   sudo zypper source-install --build-deps-only borgbackup

Alternatively, you can enumerate all build dependencies in the command
line:

   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


macOS
~~~~~

When installing borgbackup via Homebrew, the basic dependencies are
installed automatically.

For FUSE support to mount the backup archives, you need macFUSE, which
is available via github, or Homebrew:

   brew install --cask macfuse

When installing Borg via "pip", be sure to install the "llfuse" extra,
since macFUSE only supports FUSE API v2. Also, since Homebrew won't
link the installed "openssl" formula, point pkg-config to the correct
path:

   PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig" pip install borgbackup[llfuse]

When working from a borg git repo workdir, you can install
dependencies using the Brewfile:

   brew install python@3.11  # can be any supported python3 version
   brew bundle install  # install requirements from borg repo's ./Brewfile
   pip3 install virtualenv

Be aware that for all recent macOS releases you must authorize full
disk access. It is no longer sufficient to run borg backups as root.
If you have not yet granted full disk access, and you run Borg backup
from cron, you will see messages such as:

   /Users/you/Pictures/Photos Library.photoslibrary: scandir: [Errno 1] Operation not permitted:

To fix this problem, you should grant full disk access to cron, and to
your Terminal application. More information can be found here.


FreeBSD
~~~~~~~

Listed below are packages you will need to install Borg, its
dependencies, and commands to make FUSE work for using the mount
command.

   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


Windows 10's Linux Subsystem
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Note:

  Running under Windows 10's Linux Subsystem is experimental and has
  not been tested much yet.

Just follow the Ubuntu Linux installation steps. You can omit the FUSE
stuff, it won't work anyway.


Cygwin
~~~~~~

Note:

  Running under Cygwin is experimental and has not been tested much
  yet.

Use the Cygwin installer to install the dependencies:

   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


Using pip
---------

Virtualenv can be used to build and install Borg without affecting the
system Python or requiring root access.  Using a virtual environment
is optional, but recommended except for the most simple use cases.

Ensure to install the dependencies as described within From Source.

Note:

  If you install into a virtual environment, you need to **activate**
  it first ("source borg-env/bin/activate"), before running "borg".
  Alternatively, symlink "borg-env/bin/borg" into some directory that
  is in your "PATH" so you can just run "borg".

This will use "pip" to install the latest release from PyPi:

   virtualenv --python=python3 borg-env
   source borg-env/bin/activate

   # 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

To upgrade Borg to a new version later, run the following after
activating your virtual environment:

   pip install -U borgbackup  # or ... borgbackup[llfuse/pyfuse3]

When doing manual pip installation, man pages are not automatically
installed.  You can run these commands to install the man pages
locally:

   # 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


Using git
---------

This uses latest, unreleased development code from git. While we try
not to break master, there are no guarantees on anything.

Ensure to install the dependencies as described within From Source.

Version metadata is obtained dynamically at install time using
"setuptools-scm". Please ensure that your git repo either has correct
tags, or provide the version manually using the
"SETUPTOOLS_SCM_PRETEND_VERSION" environment variable.

   # 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

By default the system installation of python will be used. If you need
to use a different version of Python you can install this using
"pyenv":

   ...
   # 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!
   ...

Note:

  As a developer or power user, you always want to use a virtual
  environment.
