Borg is an excellent backup software. One of its features allows you to mount your backups and access all files in them. This is done by informing borg mount the repository and 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. So my workflow for mounting a Borg archive is typically this:

  • Determine which repository contains the archive.
  • cd into it.
  • Issue borg list . to show me the archives on that repository.
  • Pick one of those archives.
  • Pick 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).
  • And, of course, cd to the mount point or open my file manager and browse to it.

It’s easy to see how having to repeatedly issue those commands can become tedious and frustrating (not to mention error prone).

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

It works like this: the script lists all your Borg repositories and archives. You just need to select which one you want, by typing a number. Then, the archive is mounted for you and your file manager pops up with it (if you are using a graphical interface).

You also don’t need to type your passphrase, since the script also automatically sources it, if you configure BORG_PASSCOMMAND or BORG_PASSPHRASE.

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

$ borg-mount
2  # the repo number
8  # the archive number

Cool, uh?

You can find the script here.

Change the two constants on the top to reflect your paths. Also feel free to do some adapting to your use case. Then, chmod +x borg-mount and have fun.