Skip to content

Commit

Permalink
feat: Windows WebUI uses correct path separator
Browse files Browse the repository at this point in the history
  • Loading branch information
garethgeorge committed Feb 15, 2024
1 parent 276b1d2 commit f5521e7
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 6 deletions.
5 changes: 3 additions & 2 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ version: 1
before:
hooks:
- go mod tidy
- go generate ./...
- sh -c "ls && cd ./webui && npm i && npm run build && gzip ./dist/*"
- npm --prefix webui install
- sh -c "GOOS=linux go generate ./..."
- sh -c "GOOS=windows go generate ./..."

builds:
- main: .
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

Backrest is a web-accessible backup solution built on top of [restic](https://restic.net/). Backrest provides a WebUI which wraps the restic CLI and makes it easy to create repos, browse snapshots, and restore files. Additionally, Backrest can run in the background and take an opinionated approach to scheduling snapshots and orchestrating repo health operations.

By building on restic Backrest gets the advantages of restic mature feature set: restic provides fast, reliable (used by tens of thousands of individuals and by corporations in production environments), and secure backup operations. Backrest itself is built in Golang (matching restic's implementation) and is shipped as a self-contained and light weight (<20 MB on all platforms) binary with no dependecies other than restic (which backrest can download for you and keep up to date).
By building on restic, Backrest leverages restic's mature feature set. Restic provides fast, reliable (used by tens of thousands of individuals and by corporations in production environments), and secure backup operations. Backrest itself is built in Golang (matching restic's implementation) and is shipped as a self-contained and light weight (<20 MB on all platforms) binary with no dependecies other than restic (which backrest can download for you and keep up to date).

This project aims to be the easiest way to setup and get started with backups on any system. You can expect to be able to perform all operations from the web interface but should you ever need more poworeful control, you are free to browse your repo and perform operations using the [restic cli](https://restic.readthedocs.io/en/latest/manual_rest.html). Backrest safely detects and imports external operations (e.g. manual backups).

Expand Down
3 changes: 1 addition & 2 deletions backrest.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"sync"
"syscall"

rice "github.com/GeertJohan/go.rice"
"github.com/garethgeorge/backrest/gen/go/v1/v1connect"
"github.com/garethgeorge/backrest/internal/api"
"github.com/garethgeorge/backrest/internal/auth"
Expand Down Expand Up @@ -94,7 +93,7 @@ func main() {

mux := http.NewServeMux()

if box, err := rice.FindBox("webui/dist"); err == nil {
if box, err := WebUIBox(); err == nil {
mux.Handle("/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if strings.HasSuffix(r.URL.Path, "/") {
r.URL.Path += "index.html"
Expand Down
3 changes: 3 additions & 0 deletions go.work
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
go 1.21.3

use .
5 changes: 5 additions & 0 deletions go.work.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA=
github.com/census-instrumentation/opencensus-proto v0.4.1/go.mod h1:4T9NM4+4Vw91VeyqjLS6ao50K5bOcLKN6Q42XnYaRYw=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cncf/udpa/go v0.0.0-20220112060539-c52dc94e7fbe/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI=
github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
1 change: 1 addition & 0 deletions webui/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.parcel-cache
node_modules
dist
dist-windows
2 changes: 1 addition & 1 deletion webui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"scripts": {
"start": "parcel serve src/index.html",
"build": "BACKREST_BUILD_VERSION=$(git describe --tags --abbrev=0) UI_OS=unix parcel build src/index.html",
"build-windows": "set UI_OS=windows & parcel build src/index.html",
"build-windows": "BACKREST_BUILD_VERSION=$(git describe --tags --abbrev=0) UI_OS=windows parcel build src/index.html --dist-dir dist-windows",
"test": "echo \"Error: no test specified\" && exit 1",
"check": "tsc --noEmit"
},
Expand Down
12 changes: 12 additions & 0 deletions webuinix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//go:build linux || darwin
// +build linux darwin

//go:generate sh -c "rm -rf ./webui/dist && UI_OS=unix npm --prefix webui run build && gzip ./webui/dist/*"

package main

import rice "github.com/GeertJohan/go.rice"

func WebUIBox() (*rice.Box, error) {
return rice.FindBox("webui/dist")
}
12 changes: 12 additions & 0 deletions webuiwin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//go:build windows
// +build windows

//go:generate sh -c "rm -rf ./webui/dist-windows && npm --prefix webui run build-windows && gzip ./webui/dist-windows/*"

package main

import rice "github.com/GeertJohan/go.rice"

func WebUIBox() (*rice.Box, error) {
return rice.FindBox("webui/dist-windows")
}

0 comments on commit f5521e7

Please sign in to comment.