{"id":13510881,"url":"https://github.com/yboetz/pyznap","last_synced_at":"2026-04-10T05:08:12.697Z","repository":{"id":39578900,"uuid":"113581778","full_name":"yboetz/pyznap","owner":"yboetz","description":"ZFS snapshot tool written in python","archived":false,"fork":false,"pushed_at":"2024-05-12T09:12:17.000Z","size":298,"stargazers_count":201,"open_issues_count":28,"forks_count":36,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-03-05T12:48:46.377Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yboetz.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-12-08T14:16:12.000Z","updated_at":"2025-01-25T05:31:31.000Z","dependencies_parsed_at":"2024-01-13T19:38:47.200Z","dependency_job_id":"16e9bbc6-558c-466b-92b5-453c88cac186","html_url":"https://github.com/yboetz/pyznap","commit_stats":{"total_commits":323,"total_committers":6,"mean_commits":"53.833333333333336","dds":0.3900928792569659,"last_synced_commit":"bdc86c4fbd26ae85b1e7895b0ccddd31d56848a1"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yboetz%2Fpyznap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yboetz%2Fpyznap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yboetz%2Fpyznap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yboetz%2Fpyznap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yboetz","download_url":"https://codeload.github.com/yboetz/pyznap/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246355409,"owners_count":20763992,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T02:01:57.900Z","updated_at":"2025-12-13T18:03:49.887Z","avatar_url":"https://github.com/yboetz.png","language":"Python","funding_links":[],"categories":["Python","others","🛠️ ZFS tools"],"sub_categories":["ZFS Backup tools"],"readme":"# README #\n\npyznap is a ZFS snapshot management tool. It automatically takes and deletes snapshots and can send\nthem to different backup locations. You can specify a policy for a given filesystem in the\npyznap.conf file and then use cron to let it run regularly. pyznap includes zfs\nbindings for python, forked and modified from https://bitbucket.org/stevedrake/weir/.\n\n\n#### How does it work? ####\n\npyznap regularly takes and deletes snapshots according to a specified policy. You can take frequent,\nhourly, daily, weekly, monthly and yearly snapshots. 'frequent' snapshots can be taken up to once\nper minute, the frequency can be adjusted by the cronjob frequency. Old snapshots are deleted as\nyou take new ones, thinning out the history as it gets older.\n\nDatasets can also be replicated to other pools on the same system or remotely over ssh. After an\ninitial sync, backups will be done incrementally as long as there are common snapshots between the\nsource and the destination.\n\n\n#### Requirements ####\n\npyznap is written in python 3.5+ and has no dependencies. For developing and running the tests you\nneed:\n\n    pytest\n    pytest-dependency\n    paramiko\n\nYou also need the `faketime` program for some tests to simulate pyznap running over time.\n\nI suggest installing [virtualenv \u0026 virtualenvwrapper](http://docs.python-guide.org/en/latest/dev/virtualenvs/),\nso you don't clutter your system python installation with additional packages.\n\npyznap uses `mbuffer` and `lzop` (by default) to speed up zfs send/recv, and `pv` to show progress, \nbut also works if they are not installed. Other supported compression methods are: `none`, `lz4`, \n`gzip`, `pigz`, `bzip2` and `xz`.\n\nNote that ZFS needs root access to run commands. Due to this you should install pyznap under your\nroot user.\n\n\n#### How do I set it up? ####\n\npyznap can easily be installed with pip. In your virtualenv just run\n\n    pip install pyznap\n\nand pyznap \u0026 its requirements will be installed. This should also create an executable in your PATH,\neither at `/path/to/virtualenv/pyznap/bin/pyznap` or `/usr/local/bin/pyznap`. If you use your\nsystem python installation you might want to use the `--user` flag. In this case the executable will\nbe located at `~/.local/bin/pyznap`.\n\nBefore you can use pyznap, you will need to create a config file. For initial setup run\n\n    pyznap setup [-p PATH]\n\nThis will create a directory `PATH` (default is `/etc/pyznap/`) and copy a sample config there. A\nconfig for your system might look like this (remove the comments):\n\n    [rpool/filesystem]\n    frequent = 4                          # Keep 4 frequent snapshots\n    hourly = 24                           # Keep 24 hourly snapshots\n    daily = 7                             # Keep 7 daily snapshots\n    weekly = 4                            # Keep 4 weekly snapshots\n    monthly = 6                           # Keep 6 monthly snapshots\n    yearly = 1                            # Keep 1 yearly snapshot\n    snap = yes                            # Take snapshots on this filesystem\n    clean = yes                           # Delete old snapshots on this filesystem\n    dest = backup/filesystem              # Backup this filesystem on this location\n    exclude = rpool/filesystem/data/*     # Exclude these datasets for pyznap send\n\nThen set up a cronjob by creating a file under `/etc/cron.d/`\n\n    nano /etc/cron.d/pyznap\n\nand let pyznap run regularly by adding the following lines\n\n    SHELL=/bin/sh\n    PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin\n\n    */15 * * * *   root    /path/to/pyznap snap \u003e\u003e /var/log/pyznap.log 2\u003e\u00261\n\nThis will run pyznap every quarter hour to take and delete snapshots. 'frequent' snapshots can be\ntaken up to once per minute, so adjust your cronjob accordingly.\n\nIf you also want to send your filesystems to another location you can add a line\n\n    0 0 * * *   root    /path/to/pyznap send \u003e\u003e /var/log/pyznap.log 2\u003e\u00261\n\nThis will backup your data once per day at 12am.\n\nYou can also manage, send to and pull from remote ssh locations. Always specify ssh locations with\n\n    ssh:port:user@host:rpool/data\n\nIf you omit the port (`ssh::user@host:...`) the default `22` is assumed. A sample config which backs\nup a filesystem to a remote location looks like:\n\n    [rpool/data]\n    hourly = 24\n    snap = yes\n    clean = yes\n    dest = ssh:22:user@host:backup/data   # Specify ssh destination\n    dest_keys = /home/user/.ssh/id_rsa    # Provide key for ssh login. If none given, look in home dir\n    compress = gzip                       # Use gzip compression for sending over ssh\n\nTo pull a filesystem from a remote location use:\n\n    [ssh::user@host:rpool/data]           # Specify ssh source\n    key = /home/user/.ssh/id_rsa          # Provide key for ssh login. If none given, look in home dir\n    dest = tank/data\n    compress = lz4\n\nYou can exclude datasets when sending using [Unix shell-style wildcards](https://docs.python.org/3/library/fnmatch.html):\n\n    [rpool]\n    dest = backup/rpool, tank/rpool\n    exclude = rpool/data rpool/home/*/documents rpool/home/user1, rpool/home*\n\nNote that exclude rules are separated by a `,` for the different dests, and you can specify multiple\nrules for a single dest by separating them with a space. Exclude rules thus cannot contain any comma\nor whitespace.\n\nI would also suggest making sure that root has ownership for all files, s.t. no user can modify them.\nIf that is not the case just run\n\n    chown root:root -R /etc/pyznap/\n\n\n#### Config options ####\n\nHere is a list of all options you can set in the config fie:\n\n| Option             | Input           | Description |\n|--------------------|-----------------|-------------|\n| `key`              | String          | Path to ssh keyfile for source |\n| `frequent`         | Integer         | Number of frequent snapshots. These can be created every minute (whenever pyznap is called) |\n| `hourly`           | Integer         | Number of hourly snapshots |\n| `daily`            | Integer         | Number of daily snapshots |\n| `weekly`           | Integer         | Number of weekly snapshots |\n| `monthly`          | Integer         | Number of monthly snapshots |\n| `yearly`           | Integer         | Number of yearly snapshots |\n| `snap`             | yes/no          | Should snapshots be taken |\n| `clean`            | yes/no          | Should snapshots be cleaned |\n| `dest`             | List of string  | Comma-separated list of destinations where to send source filesystem |\n| `dest_key`         | List of string  | Path to ssh keyfile for dest. Comma-separated list for multiple dest |\n| `compress`         | List of string  | Compression to use over ssh, supported are gzip, lzop, bzip2, pigz, xz \u0026 lz4. Default is lzop. Comma-separated list for multiple dest |\n| `exclude`          | List of string  | Whitespace-separated list of datasets to exclude from sending. Exclude lists for different dests are separated by comma |\n| `raw_send`         | List of yes/no  | Use zfs raw send. Comma-separated list for multiple dest |\n| `resume`           | List of yes/no  | Use resumable send/receive. Comma-separated list for multiple dest |\n| `dest_auto_create` | List of yes/no  | Automatically create missing root datasets. Comma-separated list for multiple dest |\n| `retries`          | List of integer | Number of retries on connection issues. Comma-separated list for multiple dest |\n| `retry_interval`   | List of integer | Time in seconds between retries. Comma-separated list for multiple dest |\n\n\n#### Command line options ####\n\nRun `pyznap -h` to see all available options.\n\n+ --config\n\n  Specify config file. Default is `/etc/pyznap/pyznap.conf`.\n\n+ -v, --versbose\n\n  Print more verbose output.\n\n+ setup [-p PATH]\n\n  Initial setup. Creates a config dir and puts a sample config file there. You can specify the path\n  to the config dir with the `-p` flag, default is `/etc/pyznap/`.\n\n+ snap\n\n  Interface to the snapshot management tool. Has three optional arguments:\n\n  + --take\n\n    Takes snapshots according to policy in the config file.\n\n  + --clean\n\n    Deletes old snapshots according to policy.\n\n  + --full\n\n    First takes snapshots, then deletes old ones. Default when no other option is given.\n\n+ send\n\n  Interface to the zfs send/receive tool. Has two usages:\n\n  + No further option is given\n\n    Send snapshots to backup locations according to policy.\n\n  + -s SOURCE -d DESTINATION [-c COMPRESSION] [-i KEYFILE] [-j SOURCE_KEY] [-k DEST_KEY] [-e EXCLUDE] [-w] [-r] [--dest-auto-create] [--retries RETRIES] [--retry-interval RETRY_INTERVAL]\n\n    Send source filesystem to destination filesystem. If either source OR dest is a remote location,\n    you can specify the keyfile with the `-i` flag. If both source AND dest are remote, you specify\n    the keyfiles with the flag `-j` for the source and `-k` for the dest. You can also turn on\n    compression with the `-c` flag. Currently supported options are: `none`, `lzop`, `lz4`, `gzip`,\n    `pigz`, `bzip2` and `xz`. If no option is given, `lzop` is used if available. You can specify\n    multiple (whitespace separated) wildcard exclude rules with the `-e` flag. Note that you should\n    probably pass these as strings or escape the wildcard (e.g. `-e '*/data'` or `-e \\*/data`), else\n    your shell might expand the pattern. ZFS raw send can be enabled with the `-w` flag, in which case\n    compression will be disabled. Resumable zfs send/receive can be enabled with the `-r` flag. You\n    can specify a number of retries on connection issues with the `--retries` option, and set the\n    retry interval with `--retry-interval`. Normally pyznap will not create missing root datasets,\n    but you can set the `--dest-auto-create` flag to automatically create it.\n\n\n#### Usage examples ####\n\n+ Take snapshots according to policy in default config file:\n\n    `pyznap snap --take`\n\n+ Clean snapshots according to policy in another config file:\n\n    `pyznap --config /etc/pyznap/data.conf snap --clean`\n\n+ Take and clean snapshots according to policy in default config file:\n\n    `pyznap snap`\n\n+ Backup snapshots according to policy in default config file:\n\n    `pyznap send`\n\n+ Backup a single filesystem locally:\n\n    `pyznap send -s tank/data -d backup/data`\n\n+ Send a single filesystem to a remote location, using `pigz` compression:\n\n    `pyznap send -s tank/data -d ssh:20022:root@example.com:backup/data -i /root/.ssh/id_rsa -c pigz`\n\n+ Pull a single filesystem from a remote location:\n\n    `pyznap send -s ssh::root@example.com:tank/data -d backup/data -c lz4`\n\n+ Pull a single filesystem from a remote location and send it to another remote location:\n\n    `pyznap send -s ssh::root@example1.com:tank/data -d ssh::root@example2.com:backup/data -j /root/.ssh/id_rsa_1 -k /root/.ssh/id_rsa_2`\n\n+ Backup a single filesystem and exclude some datasets:\n\n    `pyznap send -s tank -d backup/tank -e '/tank/data*' '/tank/home/user1*' '*/user2/docs'`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyboetz%2Fpyznap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyboetz%2Fpyznap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyboetz%2Fpyznap/lists"}