{"id":22420466,"url":"https://github.com/meineerde/ohsnap","last_synced_at":"2026-05-02T13:34:24.195Z","repository":{"id":136799540,"uuid":"257371914","full_name":"meineerde/ohsnap","owner":"meineerde","description":"A tool to (recursively) create ZFS snapshots and run a script for each such snapshot to e.g. create a backups","archived":false,"fork":false,"pushed_at":"2020-08-06T09:28:47.000Z","size":17,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-27T04:43:44.922Z","etag":null,"topics":["backups","bash","borg","restic","zfs","zfs-snapshots"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/meineerde.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2020-04-20T18:37:20.000Z","updated_at":"2024-12-12T15:49:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"eb65f300-e10d-408e-a713-94b44d4c215a","html_url":"https://github.com/meineerde/ohsnap","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/meineerde/ohsnap","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meineerde%2Fohsnap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meineerde%2Fohsnap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meineerde%2Fohsnap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meineerde%2Fohsnap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/meineerde","download_url":"https://codeload.github.com/meineerde/ohsnap/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meineerde%2Fohsnap/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32536578,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-02T12:25:33.646Z","status":"ssl_error","status_checked_at":"2026-05-02T12:24:51.733Z","response_time":132,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["backups","bash","borg","restic","zfs","zfs-snapshots"],"created_at":"2024-12-05T16:19:51.572Z","updated_at":"2026-05-02T13:34:24.189Z","avatar_url":"https://github.com/meineerde.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OHSNAP\n\n[![CI](https://github.com/meineerde/ohsnap/workflows/CI/badge.svg)](https://github.com/meineerde/ohsnap/actions?query=workflow%3ACI)\n\nA tool to (recursively) create ZFS snapshots and run a script for each such snapshot (e.g. to create a backup). After all snapshots were handled, they are deleted again.\n\nThis tool is especially useful to create backups with [borg](https://borgbackup.readthedocs.io/) or other tools.\n\n## Example invocation\n\n```shell\n/mnt/tank/local/ohsnap/ohsnap -v --recursive --mount /var/run/ohsnap -- tank /mnt/tank/local/backup_dataset\n```\n\nSee `ohsnap --help` for details.\n\nFor this to work, you need a backup script to handle each snapshot. This script can look as follows. Of course, you can adapt it according to your specific needs. According to the above invocation, this script is in `/mnt/tank/local/backup_dataset`.\n\n```shell\n#!/bin/sh\n\nBORG=\"/mnt/tank/local/borg_wrapper\"\n\nif [[ \"$OHSNAP_DATASET\" =~ ^tank/(\\..*|backup|local)(/|$) ]]; then\n  # Don't backup those datasets\n  exit 0\nfi\n\n# Replace slashes in dataset name with a double-colon\n# to form the borg archive name\narchive=\"${OHSNAP_DATASET////::}\"\n\n\"$BORG\" create --verbose \"::${archive}--${OHSNAP_TIMESTAMP}\" .\n\"$BORG\" prune --list --prefix \"${archive}--\" \\\n  --keep-daily=8 \\\n  --keep-weekly=5 \\\n  --keep-monthly=13\n```\n\nFinally, I found it useful to use a wrapper around borg to set the local environment on each invocation. That way. you can easily mount backups and adjust things as required. I have added the wrapper script in `/mnt/tank/local/borg_wrapper`\n\n```shell\n#!/bin/sh\n\nexport BORG_CACHE_DIR=\"/mnt/tank/local/.cache/borg\"\nexport BORG_CONFIG_DIR=\"/mnt/tank/local/.config/borg\"\n\nexport BORG_RSH=\"ssh -i /mnt/tank/local/.ssh/id_ed25519 -p 23 -o ChallengeResponseAuthentication=no -o PasswordAuthentication=no -o BatchMode=yes\"\nexport BORG_REPO=\"u123456@u123456.your-storagebox.de:borg\"\n\nexport BORG_PASSPHRASE=\"SET_YOUR_PASSPHRASE_HERE\"\nexport BORG_KEY_FILE=\"/mnt/tank/local/.config/borg/keys/u123456_your_storagebox_de__borg\"\n\n/mnt/tank/local/borg-freebsd64 \"$@\"\n````\n\n## Restore\n\nIn FreeBSD (and FreeNAS), you need to mount the fuse kernel module first. Then, you can mount a borg archive using our wrapper\n\n```\nkldload fuse\n/mnt/tank/local/borg_wrapper mount ::tank::work--2020-03-31T08:17:50 /var/run/mnt/\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeineerde%2Fohsnap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmeineerde%2Fohsnap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeineerde%2Fohsnap/lists"}