2018-10-26 21:50:43 +02:00
[![GitHub license ](https://img.shields.io/github/license/zrepl/zrepl.svg )](https://github.com/zrepl/zrepl/blob/master/LICENSE)
[![Language: Go ](https://img.shields.io/badge/language-Go-6ad7e5.svg )](https://golang.org/)
[![User Docs ](https://img.shields.io/badge/docs-web-blue.svg )](https://zrepl.github.io)
2019-10-06 21:35:57 +02:00
[![Donate via Patreon ](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Fshieldsio-patreon.herokuapp.com%2Fzrepl%2Fpledges&style=flat&color=yellow )](https://www.patreon.com/zrepl)
2020-06-14 15:18:05 +02:00
[![Donate via GitHub Sponsors ](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub&style=flat&color=yellow )](https://github.com/sponsors/problame)
[![Donate via Liberapay ](https://img.shields.io/liberapay/patrons/zrepl.svg?logo=liberapay )](https://liberapay.com/zrepl/donate)
2019-10-06 21:35:57 +02:00
[![Donate via PayPal ](https://img.shields.io/badge/donate-paypal-yellow.svg )](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick& hosted_button_id=R5QSXJVYHGX96)
2018-10-26 21:50:43 +02:00
[![Twitter ](https://img.shields.io/twitter/url/https/github.com/zrepl/zrepl.svg?style=social )](https://twitter.com/intent/tweet?text=Wow:& url=https%3A%2F%2Fgithub.com%2Fzrepl%2Fzrepl)
2017-04-14 01:40:49 +02:00
# zrepl
2018-05-22 17:39:06 +02:00
zrepl is a one-stop ZFS backup & replication solution.
2017-09-24 13:42:04 +02:00
## User Documentation
2017-11-16 21:48:21 +01:00
**User Documentation** can be found at [zrepl.github.io ](https://zrepl.github.io ).
2017-09-24 13:42:04 +02:00
## Bug Reports
1. If the issue is reproducible, enable debug logging, reproduce and capture the log.
2. Open an issue on GitHub, with logs pasted as GitHub gists / inline.
## Feature Requests
2020-08-17 22:24:31 +02:00
1. Does your feature request require default values / some kind of configuration?
2017-09-24 13:42:04 +02:00
If so, think of an expressive configuration example.
2. Think of at least one use case that generalizes from your concrete application.
3. Open an issue on GitHub with example conf & use case attached.
2019-10-06 21:35:57 +02:00
4. **Optional** : [Post a bounty ](https://www.bountysource.com/teams/zrepl ) on the issue, or [contact Christian Schwarz ](https://cschwarz.com ) for contract work.
2017-09-24 13:42:04 +02:00
The above does not apply if you already implemented everything.
Check out the *Coding Workflow* section below for details.
2017-11-18 20:34:28 +01:00
## Package Maintainer Information
* Follow the steps in `docs/installation.rst -> Compiling from Source` and read the Makefile / shell scripts used in this process.
* Make sure your distro is compatible with the paths in `docs/installation.rst` .
* Ship a default config that adheres to your distro's `hier` and logging system.
* Ship a service manager file and _please_ try to upstream it to this repository.
2019-03-18 12:45:27 +01:00
* `dist/systemd` contains a Systemd unit template.
* Ship other material provided in `./dist` , e.g. in `/usr/share/zrepl/` .
2017-11-18 20:34:28 +01:00
* Use `make release ZREPL_VERSION='mydistro-1.2.3_1'`
2017-11-19 12:32:25 +01:00
* Your distro's name and any versioning supplemental to zrepl's (e.g. package revision) should be in this string
2020-05-24 17:43:42 +02:00
* Use `sudo make test-platform` **on a test system** to validate that zrepl's abstractions on top of ZFS work with the system ZFS.
2017-11-18 20:34:28 +01:00
* Make sure you are informed about new zrepl versions, e.g. by subscribing to GitHub's release RSS feed.
2017-09-24 13:42:04 +02:00
## Developer Documentation
2019-09-03 14:45:18 +02:00
zrepl is written in [Go ](https://golang.org ) and uses [Go modules ](https://github.com/golang/go/wiki/Modules ) to manage dependencies.
2018-05-22 17:39:06 +02:00
The documentation is written in [ReStructured Text ](http://docutils.sourceforge.net/rst.html ) using the [Sphinx ](https://www.sphinx-doc.org ) framework.
2020-05-24 17:43:42 +02:00
Install **build dependencies** using `./lazy.sh devsetup` .
2019-10-06 21:35:57 +02:00
`lazy.sh` uses `python3-pip` to fetch the build dependencies for the docs - you might want to use a [venv ](https://docs.python.org/3/library/venv.html ).
If you just want to install the Go dependencies, run `./lazy.sh godep` .
2017-09-24 13:42:04 +02:00
2020-05-24 17:43:42 +02:00
The **test suite** is split into pure **Go tests** (`make test-go`) and **platform tests** that interact with ZFS and thus generally **require root privileges** (`sudo make test-platform`).
Platform tests run on their own pool with the name `zreplplatformtest` , which is created using the file vdev in `/tmp` .
For a full **code coverage** profile, run `make test-go COVER=1 && sudo make test-platform && make cover-merge` .
An HTML report can be generated using `make cover-html` .
**Code generation** is triggered by `make generate` . Generated code is committed to the source tree.
2017-09-24 13:42:04 +02:00
### Project Structure
```
2018-10-26 22:05:57 +02:00
├── artifacts # build artifcats generate by make
├── cli # wrapper around CLI package cobra
├── client # all subcommands that are not `daemon`
├── config # config data types (=> package yaml-config)
│ └── samples
├── daemon # the implementation of `zrepl daemon` subcommand
│ ├── filters
2019-10-06 21:35:57 +02:00
│ ├── hooks # snapshot hooks
2018-10-26 22:05:57 +02:00
│ ├── job # job implementations
│ ├── logging # logging outlets + formatters
│ ├── nethelpers
│ ├── prometheus
│ ├── pruner # pruner implementation
│ ├── snapper # snapshotter implementation
2019-03-18 12:45:27 +01:00
├── dist # supplemental material for users & package maintainers
2019-10-06 21:35:57 +02:00
├── docs # sphinx-based documentation
2017-11-11 23:19:58 +01:00
│ ├── ** /*.rst # documentation in reStructuredText
2017-11-18 19:17:59 +01:00
│ ├── sphinxconf
│ │ └── conf.py # sphinx config (see commit 445a280 why its not in docs/)
│ ├── requirements.txt # pip3 requirements to build documentation
2017-11-11 23:19:58 +01:00
│ ├── publish.sh # shell script for automated rendering & deploy to zrepl.github.io repo
2018-10-26 22:05:57 +02:00
│ └── public_git # checkout of zrepl.github.io managed by above shell script
├── endpoint # implementation of replication endpoints (=> package replication)
├── logger # our own logger package
2019-10-06 21:35:57 +02:00
├── platformtest # test suite for our zfs abstractions (error classification, etc)
2018-10-26 22:05:57 +02:00
├── pruning # pruning rules (the logic, not the actual execution)
│ └── retentiongrid
2019-03-18 12:30:19 +01:00
├── replication
│ ├── driver # the driver of the replication logic (status reporting, error handling)
│ ├── logic # planning & executing replication steps via rpc
| | └── pdu # the generated gRPC & protobuf code used in replication (and endpoints)
│ └── report # the JSON-serializable report datastructures exposed to the client
├── rpc # the hybrid gRPC + ./dataconn RPC client: connects to a remote replication.Endpoint
│ ├── dataconn # Bulk data-transfer RPC protocol
│ ├── grpcclientidentity # adaptor to inject package transport's 'client identity' concept into gRPC contexts
│ ├── netadaptor # adaptor to convert a package transport's Connecter and Listener into net.* primitives
│ ├── transportmux # TCP connecter and listener used to split control & data traffic
│ └── versionhandshake # replication protocol version handshake perfomed on newly established connections
2018-10-26 22:05:57 +02:00
├── tlsconf # abstraction for Go TLS server + client config
2019-10-06 21:35:57 +02:00
├── transport # transport implementations
2019-03-18 12:30:19 +01:00
│ ├── fromconfig
│ ├── local
│ ├── ssh
│ ├── tcp
│ └── tls
2017-09-24 13:42:04 +02:00
├── util
2018-10-26 22:05:57 +02:00
├── version # abstraction for versions (filled during build by Makefile)
└── zfs # zfs(8) wrappers
2017-09-24 13:42:04 +02:00
```
### Coding Workflow
* Open an issue when starting to hack on a new feature
* Commits should reference the issue they are related to
* Docs improvements not documenting new features do not require an issue.
2017-10-05 21:56:37 +02:00
2017-11-12 14:10:16 +01:00
### Breaking Changes
Backward-incompatible changes must be documented in the git commit message and are listed in `docs/changelog.rst` .
* Config-breaking changes must contain a line `BREAK CONFIG` in the commit message
* Other breaking changes must contain a line `BREAK` in the commit message
2017-10-05 21:56:37 +02:00
### Glossary & Naming Inconsistencies
In ZFS, *dataset* refers to the objects *filesystem* , *ZVOL* and *snapshot* . < br />
However, we need a word for *filesystem* & *ZVOL* but not a snapshot, bookmark, etc.
Toward the user, the following terminology is used:
* **filesystem**: a ZFS filesystem or a ZVOL
* **filesystem version**: a ZFS snapshot or a bookmark
Sadly, the zrepl implementation is inconsistent in its use of these words:
variables and types are often named *dataset* when they in fact refer to a *filesystem* .
There will not be a big refactoring (an attempt was made, but it's destroying too much history without much gain).
However, new contributions & patches should fix naming without further notice in the commit message.
2017-11-11 23:32:21 +01:00
2019-10-06 21:35:57 +02:00
### RPC debugging
2020-02-23 23:24:12 +01:00
Optionally, there are various RPC-related environment variables, that if set to something != `""` will produce additional debug output on stderr:
2019-10-06 21:35:57 +02:00
https://github.com/zrepl/zrepl/blob/master/rpc/rpc_debug.go#L11
https://github.com/zrepl/zrepl/blob/master/rpc/dataconn/dataconn_debug.go#L11
https://github.com/zrepl/zrepl/blob/master/rpc/dataconn/stream/stream_debug.go#L11
https://github.com/zrepl/zrepl/blob/master/rpc/dataconn/heartbeatconn/heartbeatconn_debug.go#L11