Skip to content

Commit

Permalink
add borgbackup-viewer community container
Browse files Browse the repository at this point in the history
Signed-off-by: Simon L. <[email protected]>
  • Loading branch information
szaimen committed Jan 17, 2025
1 parent c19ba34 commit 8ae5262
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 3 deletions.
69 changes: 69 additions & 0 deletions community-containers/borgbackup-viewer/borgbackup-viewer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"aio_services_v1": [
{
"container_name": "nextcloud-aio-borgbackup-viewer",
"image_tag": "v1",
"display_name": "Borg Backup Viewer",
"documentation": "https://github.com/nextcloud/all-in-one/tree/main/community-containers/borgbackup-viewer",
"image": "szaimen/aio-borgbackup-viewer",
"internal_port": "5800",
"ports": [
{
"ip_binding": "",
"port_number": "5800",
"protocol": "tcp"
}
],
"environment": [
"BORG_HOST_ID=nextcloud-aio-borgbackup-viewer",
"WEB_AUTHENTICATION_USERNAME=nextcloud",
"WEB_AUTHENTICATION_PASSWORD=%BORGBACKUP_VIEWER_PASSWORD%",
"WEB_LISTENING_PORT=5800",
"BORG_PASSPHRASE=%BORGBACKUP_PASSWORD%"
],
"secrets": [
"BORGBACKUP_VIEWER_PASSWORD",
"BORGBACKUP_PASSWORD"
],
"volumes": [
{
"source": "nextcloud_aio_backup_cache",
"destination": "/root",
"writeable": true
},
{
"source": "%NEXTCLOUD_DATADIR%",
"destination": "/nextcloud_aio_volumes/nextcloud_aio_nextcloud_data",
"writeable": true
},
{
"source": "nextcloud_aio_mastercontainer",
"destination": "/nextcloud_aio_volumes/nextcloud_aio_mastercontainer",
"writeable": true
},
{
"source": "%BORGBACKUP_HOST_LOCATION%",
"destination": "/mnt/borgbackup",
"writeable": true
},
{
"source": "nextcloud_aio_elasticsearch",
"destination": "/nextcloud_aio_volumes/nextcloud_aio_elasticsearch",
"writeable": true
},
{
"source": "nextcloud_aio_redis",
"destination": "/mnt/redis",
"writeable": true
}
],
"devices": [
"/dev/fuse"
],
"cap_add": [
"SYS_ADMIN"
],
"apparmor_unconfined": true
}
]
}
15 changes: 15 additions & 0 deletions community-containers/borgbackup-viewer/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## Borgbackup Viewer
This container allows to view the local borg repository in a web session. It also allows you to restore files and folders from the backup by using desktop programs in a web browser.

### Notes
- After adding and starting the container, you need to visit `https://ip.address.of.this.server:5800` in order to log in with the user `nextcloud` and the password that you can retrieve when running `sudo docker inspect nextcloud-aio-borgbackup-viewer | grep WEB_AUTHENTICATION_PASSWORD`.
- Then, you should see a terminal. There type in `borg mount /mnt/borgbackup/borg /tmp/borg` to mount the backup archive at `/tmp/borg` inside the container. Afterwards type in `nautilus /tmp/borg` which will show a file explorer and allows you to see all the files. You can then copy files and folders back to their initial mountpoints inside `/nextcloud_aio_volumes/`, `/host_mounts/` and `/docker_volumes/`. ⚠️ Be very carefully while doing that as can break your instance!
- After you are done with the operation, click on the terminal in the background and press `[CTRL]+[c]` multiple times to close any open application. Then run `umount /tmp/borg` to unmount the mountpoint correctly. You should afterwards remove the container for better security again from the stack: https://github.com/nextcloud/all-in-one/tree/main/community-containers#how-to-remove-containers-from-aios-stack
- See https://github.com/nextcloud/all-in-one/tree/main/community-containers#community-containers how to add it to the AIO stack

### Repository
https://github.com/szaimen/aio-borgbackup-viewer

### Maintainer
https://github.com/szaimen

10 changes: 7 additions & 3 deletions php/src/Docker/DockerActionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -541,19 +541,23 @@ public function CreateContainer(Container $container) : void {
$mounts = [];

// Special things for the backup container which should not be exposed in the containers.json
if ($container->GetIdentifier() === 'nextcloud-aio-borgbackup') {
if (str_starts_with($container->GetIdentifier(), 'nextcloud-aio-borgbackup')) {
// Additional backup directories
foreach ($this->getAllBackupVolumes() as $additionalBackupVolumes) {
if ($additionalBackupVolumes !== '') {
$mounts[] = ["Type" => "volume", "Source" => $additionalBackupVolumes, "Target" => "/nextcloud_aio_volumes/" . $additionalBackupVolumes, "ReadOnly" => false];
}
}

// Make volumes read only in case of borgbackup container. The viewer makes them writeable
$isReadOnly = $container->GetIdentifier() === 'nextcloud-aio-borgbackup';

foreach ($this->configurationManager->GetAdditionalBackupDirectoriesArray() as $additionalBackupDirectories) {
if ($additionalBackupDirectories !== '') {
if (!str_starts_with($additionalBackupDirectories, '/')) {
$mounts[] = ["Type" => "volume", "Source" => $additionalBackupDirectories, "Target" => "/docker_volumes/" . $additionalBackupDirectories, "ReadOnly" => true];
$mounts[] = ["Type" => "volume", "Source" => $additionalBackupDirectories, "Target" => "/docker_volumes/" . $additionalBackupDirectories, "ReadOnly" => $isReadOnly];
} else {
$mounts[] = ["Type" => "bind", "Source" => $additionalBackupDirectories, "Target" => "/host_mounts" . $additionalBackupDirectories, "ReadOnly" => true, "BindOptions" => ["NonRecursive" => true]];
$mounts[] = ["Type" => "bind", "Source" => $additionalBackupDirectories, "Target" => "/host_mounts" . $additionalBackupDirectories, "ReadOnly" => $isReadOnly, "BindOptions" => ["NonRecursive" => true]];
}
}
}
Expand Down

0 comments on commit 8ae5262

Please sign in to comment.