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.

However, in many cases, you don’t know which archive you need until you see a list of what is available. Besides that, archive names can be quite tedious to type. So, my workflow for mounting a Borg archive is typically like this:

  • Determine which repository contains the archive I want to mount.
  • cd into it.
  • Run borg list . to list the archives on that repository.
  • Decide for one of those archives.
  • Make an empty directory for the mounting.
  • Tell Borg my passphrase.
  • Mount the archive with borg .::${archive_name} ${mount_path}. This is the most tedious part since we need to type the full archive name and the mount path.
  • cd to 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.

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 Borg repositories and 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.

Also, there is no need to type your passphrase, since it is automatically sourced if you configure BORG_PASSCOMMAND.

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

$ borg-mount
2  # the repo number
8  # the archive number
↵  # umount when done

Cool, uh?

Downloading and using

You can find the script here.

At the top, you’ll see the configuration variables. Change them accordingly. Then, chmod +x borg-mount to make it executable.

It runs without arguments. Optionally, you can pass it a path. It will override repos_dir and BORG_PASSCOMMAND will be ignored. This option is handy if, at some point, you need to deal with repositories placed on a different path and don’t want to change your configuration.