My off-site backup involves sending borgbackup archives of VM images to a remote synology server. I recently needed to restore a single file from one of the VM images stored within this borg backup repository on the remote server. My connection to this server is not very fast so I didn’t want to wait to download the entire image file to mount it locally.
My solution was to mount the remote borgbackup repository on my local machine over SSH so I could poke around for and copy the specific file I wanted. This requires the borgbackup binary to be present on the remote machine. Since it’s a synology, I simply copied the standalone binary over.
The restore process was complicated by the fact that the VM disk image is owned by root, so in order to access the file I needed to mount the remote repository as root.
This is the process:
- Set BORG_REMOTE_PATH
- export BORG_REMOTE_PATH=<PATH_TO_BORG_BINARY_ON_REMOTE_SYSTEM>
- (Arch Linux): install python-llfuse
- Mount repository over SSH:
borg mount <USER>@<REMOTE_SYSTEM>:<PATH_TO_REMOTE_BORGBACKUP_REPOSITORY>::<BACKUP_NAME> <MOUNT_FOLDER>
- Follow disk image mounting process
losetup -Pr -f <PATH_TO_MOUNTED_BORGBACKUP>/<FILENAME_OF_VM_IMAGE>
mount -o ro /dev/loop0p2 /mnt/loop0/
- Follow reverse to unmount when done:
losetup -d /dev/loop0
borg umount <MOUNT_FOLDER>
Success! I was able to restore an individual file within a raw VM image backup on a remote Borgbackup repository using this method.