Rewrite makefile & travis

This commit is contained in:
jo 2019-11-07 17:46:30 +01:00
parent c80485eac5
commit 521016ee00
4 changed files with 54 additions and 176 deletions

View file

@ -1,39 +1,30 @@
os: linux
sudo: false
language: go
sudo: false
go:
- "1.7.x"
- "1.8.x"
- "1.9.x"
- "1.10.x"
- 1.11.x
- 1.12.x
- 1.13.x
- master
matrix:
allow_failures:
- go: master
branches:
only:
- master
notifications:
email:
on_success: always
env:
- GO111MODULE=on
install:
- export GOBIN="$GOPATH/bin"
- export PATH="$PATH:$GOBIN"
- go get -u github.com/golang/lint/golint
- go install
- go get -u golang.org/x/lint/golint
- go get golang.org/x/tools/cmd/goimports
- go get github.com/restic/calens
script:
- go install
- go test -v . ./cmd/rest-server
- go run build.go -v -T
- diff <(goimports -d *.go) <(printf "")
- calens
after_success:
- go build
- go test -v ./...
- diff <(golint *.go) <(printf "")
- diff <(goimports -d *.go) <(printf "")

View file

@ -1,39 +1,18 @@
# Copyright © 2017 Zlatko Čalušić
#
# Use of this source code is governed by an MIT-style license that can be found in the LICENSE file.
#
PROJECT_NAME := rest-server
DOCKER_IMAGE ?= restic/$(PROJECT_NAME)
MAIN := ./cmd/$(PROJECT_NAME)/main.go
VERSION := $(shell git describe --tags --abbrev=0)
DOCKER_IMAGE ?= restic/rest-server
install:
go install
REST_SERVER_VERSION := $(strip $(shell cat VERSION))
build: install
go build -o $(PROJECT_NAME) $(MAIN)
.PHONY: default rest-server install uninstall docker_build docker_push clean
docker_build: install
docker build -t $(DOCKER_IMAGE):$(VERSION) .
docker tag $(DOCKER_IMAGE):$(VERSION) $(DOCKER_IMAGE):latest
default: rest-server
rest-server:
@go run build.go
install: rest-server
/usr/bin/install -m 755 rest-server /usr/local/bin/rest-server
uninstall:
rm -f /usr/local/bin/rest-server
docker_build:
docker pull golang:alpine
docker run --rm -it \
-v $(CURDIR):/go/src/github.com/restic/rest-server \
-w /go/src/github.com/restic/rest-server \
golang:alpine \
go run build.go
docker pull alpine
docker build -t $(DOCKER_IMAGE):$(REST_SERVER_VERSION) .
docker tag $(DOCKER_IMAGE):$(REST_SERVER_VERSION) $(DOCKER_IMAGE):latest
docker_push:
docker_push: docker_build
docker push $(DOCKER_IMAGE):$(REST_SERVER_VERSION)
docker push $(DOCKER_IMAGE):latest
clean:
rm -f rest-server

126
README.md
View file

@ -20,68 +20,45 @@ The required version of restic backup client to use with Rest Server is [v0.7.1]
#### Build
```make```
or
```go run build.go```
```
make build
```
If all goes well, you'll find the binary in the current directory.
Alternatively, you can compile and install it in your $GOBIN with a standard `go install ./cmd/rest-server`. But, beware, you won't have version info built into binary when compiled that way!
#### Install
```make install```
Installs the binary as `/usr/local/bin/rest-server`.
Alternatively, you can install it manually anywhere you want. It's a single binary, there are no dependencies.
### Docker
#### Build image
```make docker_build```
#### Pull image
```docker pull restic/rest-server```
## Usage
To learn how to use restic backup client with REST backend, please consult [restic manual](http://restic.readthedocs.io/en/latest/030_preparing_a_new_repo.html#rest-server).
```
rest-server --help
Run a REST server for use with restic
Run a restic server
Usage:
rest-server [flags]
./rest-server [flags]
Flags:
-V, --version show version and quit
--append-only enable append only mode
--cpu-profile string write CPU profile to file
--debug output debug messages
-h, --help help for rest-server
--cpu-profile string CPU profile file
--debug debug messages
-h, --help help for ./rest-server
--listen string listen address (default ":8000")
--log string log HTTP requests in the combined log format
--no-auth disable .htpasswd authentication
--log string log files
--max-size int maximum data repo size in bytes
--no-auth disable http authentication
--path string data directory (default "/tmp/restic")
--private-repos users can only access their private repo
--prometheus enable Prometheus metrics
--tls turn on TLS support
--tls-cert string TLS certificate path
--tls-key string TLS key path
-V, --version show version and quit
--tls enabled TLS
--tls-cert string TLS certificate file
--tls-key string TLS key file
```
By default the server persists backup data in `/tmp/restic`. To start the server with a custom persistence directory and with authentication disabled:
```
rest-server --path /user/home/backup --no-auth
rest-server --no-auth
```
To authenticate users (for access to the rest-server), the server supports using a `.htpasswd` file to specify users. You can create such a file at the root of the persistence directory by executing the following command (note that you need the `htpasswd` program from Apache's http-tools). In order to append new user to the file, just omit the `-c` argument. Only bcrypt and SHA encryption methods are supported, so use -B (very secure) or -s (insecure by today's standards) when adding/changing passwords.
@ -113,43 +90,6 @@ Rest Server uses exactly the same directory structure as local backend, so you s
There's an example [systemd service file](https://github.com/restic/rest-server/blob/master/examples/systemd/rest-server.service) included with the source, so you can get Rest Server up & running as a proper Systemd service in no time. Before installing, adapt paths and options to your environment.
### Docker
By default, image uses authentication. To turn it off, set environment variable `DISABLE_AUTHENTICATION` to any value.
Persistent data volume is located to `/data`.
#### Start server
```
docker run -p 8000:8000 -v /my/data:/data --name rest_server restic/rest-server
```
It's suggested to set a container name to more easily manage users (see next section).
You can set environment variable `OPTIONS` to any extra flags you'd like to pass to rest-server.
#### Manage users
##### Add user
```
docker exec -it rest_server create_user myuser
```
or
```
docker exec -it rest_server create_user myuser mypassword
```
##### Delete user
```
docker exec -it rest_server delete_user myuser
```
## Prometheus support and Grafana dashboard
The server can be started with `--prometheus` to expose [Prometheus](https://prometheus.io/) metrics at `/metrics`.
@ -157,7 +97,7 @@ The server can be started with `--prometheus` to expose [Prometheus](https://pro
This repository contains an example full stack Docker Compose setup with a Grafana dashboard in [examples/compose-with-grafana/](examples/compose-with-grafana/).
## Why use Rest Server?
## Why use Restic Server?
Compared to the SFTP backend, the REST backend has better performance, especially so if you can skip additional crypto overhead by using plain HTTP transport (restic already properly encrypts all data it sends, so using HTTPS is mostly about authentication).
@ -168,35 +108,3 @@ Finally, the Rest Server implementation is really simple and as such could be us
## Contributors
Contributors are welcome, just open a new issue / pull request.
## License
```
The BSD 2-Clause License
Copyright © 2015, Bertil Chapuis
Copyright © 2016, Zlatko Čalušić, Alexander Neumann
Copyright © 2017, The Rest Server Authors
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
```

View file

@ -17,20 +17,20 @@ var conf = &restserver.Config{
func init() {
flags := rootCmd.Flags()
flags.StringVar(&conf.ListenAddr, "listen", conf.ListenAddr, "listen address")
flags.StringVar(&conf.Path, "path", conf.Path, "data directory")
flags.Int64Var(&conf.MaxRepoSize, "max-size", conf.MaxRepoSize, "maximum data repo size in bytes")
flags.StringVar(&conf.Log, "log", conf.Log, "log files")
flags.StringVar(&conf.Path, "path", conf.Path, "data repository path")
flags.Int64Var(&conf.MaxRepoSize, "max-size", conf.MaxRepoSize, "maximum data repository size in bytes")
flags.StringVar(&conf.CPUProfile, "cpu-profile", conf.CPUProfile, "CPU profile file")
flags.BoolVar(&conf.Debug, "debug", conf.Debug, "debug messages")
flags.StringVar(&conf.Log, "log", conf.Log, "log file path")
flags.BoolVar(&conf.Debug, "debug", conf.Debug, "enabled debug messages")
flags.StringVar(&conf.CPUProfile, "cpu-profile", conf.CPUProfile, "CPU profile file path")
flags.BoolVar(&conf.TLS, "tls", conf.TLS, "enabled TLS")
flags.StringVar(&conf.TLSCertFile, "tls-cert", conf.TLSCertFile, "TLS certificate file")
flags.StringVar(&conf.TLSKeyFile, "tls-key", conf.TLSKeyFile, "TLS key file")
flags.StringVar(&conf.TLSCertFile, "tls-cert", conf.TLSCertFile, "TLS certificate file path")
flags.StringVar(&conf.TLSKeyFile, "tls-key", conf.TLSKeyFile, "TLS key file path")
flags.BoolVar(&conf.NoAuth, "no-auth", conf.NoAuth, "disable http authentication")
flags.BoolVar(&conf.AppendOnly, "append-only", conf.AppendOnly, "enable append only mode")
flags.BoolVar(&conf.PrivateRepos, "private-repos", conf.PrivateRepos, "users can only access their private repo")
flags.BoolVar(&conf.PrivateRepos, "private-repos", conf.PrivateRepos, "enable private repositories")
flags.BoolVar(&conf.Prometheus, "prometheus", conf.Prometheus, "enable Prometheus metrics")
}