Git Product home page Git Product logo

caddy's Introduction

Caddy restic plugin

This plugin makes it easy to run a restic backup server! This plugin uses restic/rest-server to make your backup repositories reachable over HTTPS.

Using restic's "rest" backend instead of the "sftp" backend is likely to provide faster transfer speeds because it avoids a lot of SFTP's flow control problems, where transfers slow down more than necessary.

The advantage of using this plugin over the bare rest-server command is that Caddy provides HTTPS by managing TLS certificates for you, so you always get a secure access point for your repositories and you don't have to reload the server to renew certificates.

Usage

The restic plugin requires authentication using basicauth because otherwise anyone could access your backups. (Yes, restic backups are encrypted, but people could still delete them, etc.) The examples here are shown in conjunction with the basicauth directive for this reason. Requests to the rest-server endpoints without authentication will be forbidden. Caddy uses HTTPS by default, and it is not safe to use this plugin without HTTPS (TLS). Do not disable TLS.

The underlying rest-server needs a data path within which the restic repositories are stored. By default, it is /tmp/restic, but you should change this to a non-temporary path for storing actual backups.

The syntax of the restic directive is:

restic [base_path [data_path]]

The restic plugin can be used without arguments:

basicauth / user pass
restic

This configures all requests to be processed by rest-server using the default data path. This is useful mostly for testing or experimenting.

basicauth /backups user pass
restic    /backups

This does the same thing, but only for HTTP requests to /backups. The data path is the same.

basicauth /backups user pass
restic    /backups /home/me/backups

This sets the base path of requests to be /backups and the data path on disk to be /home/me/backups. In other words, all requests to /backup will be handled by the rest-server to manage restic repositories within /home/me/backups.

Once your server is running, you can access your backups via HTTPS with restic quite easily:

$ restic --repo "rest:https://user:[email protected]/repo_name" snapshots

The path to the repository (repo_name) will be relative to the data path you specified in your Caddyfile.

caddy's People

Contributors

claui avatar fd0 avatar mholt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

caddy's Issues

Incompatible with caddy 1.0.0+

This plugin breaks a caddy build with the following message:

.go/pkg/mod/github.com/restic/[email protected]/setup.go:19:16: undefined: restserver.Server
.go/pkg/mod/github.com/restic/[email protected]/setup.go:42:19: undefined: restserver.NewHandler

The issue is maybe related to caddy requiring Go modules to build since its 1.0.0. Introducing modules support is quite easy, simply run go mod init github.com/restic/caddy in the root of your repository and commit go.sum and go.mod that are created by the aforementioned command.

Plugin not working correctly in a multisite configuration

I might be something incorrectly, but here's my Caddy config file.

https://example.com/backups/repo1 {

	tls {
        	dns cloudflare
	}

	basicauth user pass {
        	/
	}

	restic / /home/backups/repo1

}



https://example.com/backups/repo2 {

	tls {
        	dns cloudflare
	}

	basicauth user pass {
        	/
	}

	restic / /home/backups/repo2

}


https://example.com/backups/repo3 {

	tls {
        	dns cloudflare
	}

	basicauth user pass {
        	/
	}

	restic / /home/backups/repo3

}

I can access all virtual paths, however it only writes to the physical path of the last site configured with restic.

So I can connect to repo1, repo2, and repo3 fine, but it all attempts to save under repo3.

Caddy's import path has changed

(I know I could change this myself in a jiffy -- I'm just filing issues for as many plugins as I can, then I can come back and make a commit if someone doesn't beat me to it.)

Caddy's import path (and Go module name) has changed from

github.com/mholt/caddy

to

github.com/caddyserver/caddy

Unfortunately, Go modules are not yet mature enough to handle a change like this (see https://golang.org/issue/26904 - "haven't implemented that part yet" but high on priority list for Go 1.14) which caught me off-guard. Using Go module's replace feature didn't act the way I expected, either. Caddy now fails to build with plugins until they update their import paths.

I've hacked a fix into the build server, so downloading Caddy with your plugin from our website should continue working without any changes on your part, for now. However, please take a moment and update your import paths, and do a new deploy on the website, because the workaround involves ignoring module checksums and performing a delicate recursive search-and-replace.

I'm terribly sorry about this. I did a number of tests and dry-runs to ensure the change would be smooth, but apparently some unknown combination of GOPATH, Go modules' lack of maturity, and other hidden variables in the system or environment must have covered up something I missed.

This bash script should make it easy (run it from your project's top-level directory):

find . -name '*.go' | while read -r f; do
	sed -i.bak 's/\/mholt\/caddy/\/caddyserver\/caddy/g' $f && rm $f.bak
done

We use this script in the build server as part of the temporary workaround.

Let me know if you have any questions! Sorry again for the inconvenience.

add support for append-only option

I didn't find a way to use the option --append-only from the last rest-server in this plugin.
Having feature parity between server and plugin would be great.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.