Mount Borg backups with ease

Borg is an excellent backup software. One of Borg’s features is mounting the backups and accessing all files in them. This is done by running borg mount with the path to the repository and the name of the archive you want to mount.

My workflow for mounting a Borg archive is typically like this:

  • Make an empty directory for the mounting, taking care of the permissions.

  • Determine which repository contains the archive I want to mount and cd into it.

  • Export my Borg passphrase, so I’m not asked for it multiple times.

  • Run borg list . to list the archives on that repository and decide for one of those.

  • Mount the archive with borg .::${archive_name} ${mount_path}. This is the most tedious step since we need to type the full archive name and the mount path.

    Note from 2023-06-07: This became easier as Borg added support for shell tab completion. Also, you can now mount the entire repository instead of choosing an archive in advance.

  • cd into the mount point or open my file manager and browse to it.

  • After I’m done, remember to type a command to umount the archive.

  • Delete the mount point that I created.

It’s easy to see how repeatedly typing those commands can become tedious and frustrating, not to mention error prone.

So I wrote a simple Bash script to automate this task.

The solution

It works like this:

  1. It first lists all your archives.
  2. You select one by simply typing a number.
  3. The archive is mounted and your file manager pops up with it (if you are using a graphical interface).
  4. After you are done, you can just press enter and the archive will be umounted.

So from all that huge list of commands, we came to just type this:

$ borg-mount /repo/path
foobar # type the passphrase (if not exported)
8 # the archive number
↵ # umount when done

Cool, uh?

Downloading and running

You can find the script here. Near the top you’ll find a configuration section with the values to pass to borg mount command. You’ll probably want to change the file manager command and empty the other values before first running it.


Updates

  • : Describe new features added to the script.
  • : Update instructions to run the script.
  • : Add note about features in Borg.

  • All posts · Show comments