ZFShotter is a utility designed to automate the creation of ZFS snapshots and replicate them to remote servers
- Automates the creation of ZFS snapshots.
- Flexible prune policy pipeline to automate the pruning of old snapshots.
- Supports replication of snapshots to remote servers (push-based via ssh).
- Easy configuration file for customizable settings.
To install ZFShotter, follow these steps:
-
Clone the repository to your desired directory (e.g.,
/opt/,/usr/local/, or wherever you want). In this documentation, we will use/usr/local:git clone https://github.com/mojtabamoaddab/zfshotter.git /usr/local/zfshotter
-
Configure Jobs according configuration section.
-
Define a job scheduler (e.g., cron or systemd-timer) to run the jobs with following command:
/usr/local/zfshotter/bin/zfshotter.sh <JOB_NAME>
The configuration for ZFShotter is organized into a config directory,
which contains three subdirectories: jobs, datasets, and replications.
Each subdirectory holds .conf files that define the respective configurations.
config/
├── jobs/
│ └── sample.conf
├── datasets/
│ └── sample.conf
└── replications/
└── sample.conf
A job is a sequence of operations that involves taking snapshots, pruning old ones, and then replicating them.
You can see config/jobs/sample.conf to possible configuration options.
Supported prune-policies (can be combined with |):
| Prune Policy | Description | Example |
|---|---|---|
keep_all |
Keep all snapshots (no prune) | |
keep_for <duration> |
Keep snapshots within specified duration | keep_for 4d12h |
keep_n <n> |
Keep the last n snapshots | keep_n 20 |
keep_regex <regex> |
Keep snapshots that match the specified regex pattern in their name | keep_regex "^manual" |
keep_time_pattern <time-format> <regex> |
Keep snapshots whose creation time (formatted as specified) matches the given regex | keep_time_pattern "%H" "00" |
The datasets configuration file is a simple list of datasets (for taking snapshots, pruning, or replicating) along with some per-dataset options. Each line contains a dataset path followed by optional key-value pairs separated by semicolons.
Example:
path/to/dataset; option1=value1; option2=value2
This section defines the remote server for replicating snapshots and the datasets to replicate.
You can see config/replications/sample.conf to possible configuration options.
This project is licensed under the GPL-3.0-or-later License -
see the COPYING file for details.