1
0
Fork
You've already forked madcow
0
madcow is a helper for managing snapshots on the ZFS filesystem
  • Go 98%
  • Makefile 2%
Find a file
2026年01月29日 11:14:09 +00:00
cmd fixes license 2025年09月16日 00:47:33 +00:00
images local snaps sync ( close #10 ) 2023年01月13日 13:52:40 +00:00
internal change zerolog to slog ( close #44 ) 2025年09月16日 00:39:25 +00:00
pkg change zerolog to slog ( close #44 ) 2025年09月16日 00:39:25 +00:00
.gitignore gitignore 2023年03月15日 18:38:13 +00:00
CHANGELOG.md changelog 2025年09月16日 00:48:28 +00:00
GEMINI.md change zerolog to slog ( close #44 ) 2025年09月16日 00:39:25 +00:00
go.mod change zerolog to slog ( close #44 ) 2025年09月16日 00:39:25 +00:00
go.sum change zerolog to slog ( close #44 ) 2025年09月16日 00:39:25 +00:00
LICENSE fixes license 2025年09月16日 00:47:33 +00:00
main.go fixes license 2025年09月16日 00:47:33 +00:00
Makefile add FreeBSD release 2023年03月13日 12:39:20 +00:00
README.md readme 2026年01月29日 11:14:09 +00:00
tools.go add snapshots pruning ( close #8 ) 2022年12月19日 08:40:15 -06:00

madcow

The madcow app is a helper for managing snapshots and clones on the ZFS filesystem.

11:10:59 ❯ madcow --version
 __________________________________
( Version: v0.0.11 )
( Build: 2025年11月27日_13:37:41TUTC )
 ----------------------------------
 \ ^__^
 \ (Oo)\_______
 (__)\ )\/\
 | ||----w |
 || ||
11:07:03 ❯ madcow list raw
DataSet: tank/photos/raw
Size: 813 GB (×ばつ 1.04 = 846 GB)
Size Snapshots: 2.7 GB
Size Children: 0 B
Mountpoint: /home/dimus/photos/raw
Template: Production
+----+------------+---------------------+---------+----------+------+
| # | ANNOTATION | TIMESTAMP UTC | WRITTEN | CATEGORY | HELD |
+----+------------+---------------------+---------+----------+------+
| 1 | madcow | 2025年09月30日 23:16:32 | 534 GB | monthly | |
| 2 | madcow | 2025年10月30日 23:16:51 | 253 GB | monthly | |
| 3 | madcow | 2025年11月30日 23:31:15 | 78 kB | monthly | |
| 4 | madcow | 2025年12月28日 23:31:06 | - | daily | |
| 26 | madcow | 2026年01月19日 23:30:28 | - | daily | |
| 27 | madcow | 2026年01月20日 23:31:58 | 29 GB | daily | |
| 28 | madcow | 2026年01月21日 21:32:02 | 17 MB | daily | |
| 29 | madcow | 2026年01月22日 23:30:41 | - | daily | |
| 30 | madcow | 2026年01月23日 23:31:55 | 152 kB | daily | |
| 31 | madcow | 2026年01月24日 23:30:10 | 156 kB | daily | |
| 32 | madcow | 2026年01月25日 23:31:15 | - | daily | |
| 33 | madcow | 2026年01月26日 23:30:06 | - | daily | |
| 34 | madcow | 2026年01月27日 10:31:26 | - | - | |
| 35 | madcow | 2026年01月27日 11:30:30 | - | recent | |
| 36 | madcow | 2026年01月27日 12:31:23 | - | recent | |
| 68 | madcow | 2026年01月29日 08:30:47 | - | recent | |
| 69 | madcow | 2026年01月29日 09:31:09 | - | recent | |
| 70 | madcow | 2026年01月29日 10:30:26 | - | recent | |
+----+------------+---------------------+---------+----------+------+
bottom of tank/photos/raw

Introduction

This project is a quite powerful manager of ZFS snapshots. It allows to show the summary of every dataset and its snapshots, create, prune, see difference, bulk delete snapshots in a very efficient manner.

It can also sync snapshots from one dataset to another, but this functionality is not ready for production.

Usage

Delegating ZFS privileges to a group

To lessen security risks, madcow does not try to gain superuser privileges internally with sudo or other commands. Therefore, to be able to use all commands of madcow locally and remotely, delegate the required ZFS privileges to a group. In this example, we use the wheel group, but it may be beneficial to create a special zfsadmin or similar group. You have to do this for each zpool you want to be accessible to all madcow commands. Permissions are recursive by default and are available to all children of the zpools.

sudo zfs allow wheel create,destroy,mount,mountpoint,diff,snapshot,send,receive,hold,release,rollback,compression a-zpool
sudo zfs allow wheel create,destroy,mount,mountpoint,diff,snapshot,send,receive,hold,release,rollback,compression another-zpool
...

CLI completion

To add completion to madcow commands generate script according to your shell, save it somewhere and source it in your initiation script.

mkdir ~/.config/madcow
madcow completion bash > ~/.config/madcow/compl.bash
echo "source ~/.config/madcow/compl.bash" >> ~/.bashrc

List

List command uses regular expressions to find datasets:

madcow list tank/home
## or using mountpoint
madcow list /home
## find exact match of /home
madcow list '^tank\/home$'
## find datasets starting with h
madcow list '\/h.*'
## or showing all snapshots at once
madcow list
## JSON output
madcow list -j
## if at the root of a dataset, list recursively
madcow list -r `pwd`

Templates

Provide list of existing templates for snapshots pruning.

madcow templates
## JSON output
madcow templates -j

Diff

To show diff between snapshots (requires superuser, or "sys_mount" or "diff" privileges)

sudo madcow diff -R 34:36 /home

You need to run madcow list command first to find correct numbers for comparison.

Rollback

To rollback a dataset to the state of earlier snapshots.

sudo madcow rollback -R 5 /home
sudo madcow rollback -R 5 tank/home
# to skip confirmation
sudo madcow rollback -R 5 -y tank/home

Destroy

To delete a range of snapshots

sudo madcow destroy -R 34:35 /home
# to delete a snapshot without confirmation dialog
sudo madcow destroy -R 34:35 -y /home
# to delete one snapshot
sudo madcow destrooy -R 34 /home
# to delete all snapshots before given one
sudo madcow destroy -R :35 /home
# to delete all snapshots after the given one
sudo madcow destroy -R 35: /home

Create

To create snapshots for datasets configured in madcow.yaml

sudo madcow create

To create a snapshot for a particular dataset

# using mountpoint
sudo madcow create /home
# using dataset's name
sudo madcow create zroot/home

Prune

Prune removes snapshots according to a pruning template. The template can be configured in madcow.yaml file. If there is no configuration for a dataset, than the Default template will be used.

Pruning progressively removes more and more snapshots. As a rule of thumb the more deletions/modifications happen in the dataset, the earlier the oldest snapshot should be deleted to save space.

To prune all datasets

sudo madcow prune -y
# pruning interactively
sudo madcow prune

To prune a particular dataset

# using mountpoint
sudo madcow prune /home
# using dataset's name
sudo madcow prune zroot/home

Clones List

Clones List shows existing clones, if any. Clones are created from snapshots and can be used similar to 'normal' datasets. Clones take very little space because they keep only newly added data, the rest is located in the snapshot. A snapshot that was used for one or more clone creation cannot be removed until its clones are removed.

madcow clones list