{"id":13586817,"url":"https://github.com/bdrewery/zfstools","last_synced_at":"2025-04-05T07:05:59.057Z","repository":{"id":2452668,"uuid":"3423847","full_name":"bdrewery/zfstools","owner":"bdrewery","description":"Various ZFS scripts. Most notably, zfs-auto-snapshot, a ruby clone of OpenSolaris auto snapshotting","archived":false,"fork":false,"pushed_at":"2024-03-25T19:38:49.000Z","size":90,"stargazers_count":143,"open_issues_count":28,"forks_count":29,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-03-29T06:05:57.575Z","etag":null,"topics":["opensolaris","ruby","zfs","zfs-snapshots"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bdrewery.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":"2012-02-12T18:54:49.000Z","updated_at":"2025-03-18T23:19:30.000Z","dependencies_parsed_at":"2024-11-06T05:32:56.387Z","dependency_job_id":"19627d6b-86fc-40b4-9b5f-1f6a4271b6d5","html_url":"https://github.com/bdrewery/zfstools","commit_stats":{"total_commits":122,"total_committers":5,"mean_commits":24.4,"dds":0.09836065573770492,"last_synced_commit":"0ac02eeca62920a87432da03e8dfab0aa71fbfcb"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdrewery%2Fzfstools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdrewery%2Fzfstools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdrewery%2Fzfstools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdrewery%2Fzfstools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bdrewery","download_url":"https://codeload.github.com/bdrewery/zfstools/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247299832,"owners_count":20916190,"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":["opensolaris","ruby","zfs","zfs-snapshots"],"created_at":"2024-08-01T15:05:49.959Z","updated_at":"2025-04-05T07:05:59.039Z","avatar_url":"https://github.com/bdrewery.png","language":"Ruby","readme":"# ZFS Tools\n\nVarious scripts for administrating ZFS. Modeled after [time-sliderd](https://web.archive.org/web/20091219060106/http://mail.opensolaris.org/pipermail/zfs-discuss/2009-November/033882.html) and [ZFS Automatic Snapshots](https://web.archive.org/web/20090707205453/http://blogs.sun.com/timf/entry/zfs_automatic_snapshots_0_12) from OpenSolaris\n\n## Setup\n\nInstall the gem.\n\n## Production version\n\n    gem install zfstools\n\n### Development version\n\n    rake install\n\nSetup crontab entries for scripts wanted. See below.\n\n## Scripts\n\n### zfs-auto-snapshot\n\nThis will handle automatically snapshotting datasets similar to time-sliderd from OpenSolaris. Setup allows you to define your own intervals, snapshot names, and how many to keep for each interval. Zero-sized snapshots will automatically be cleaned up.\n\n### Usage\n\n    /usr/local/bin/zfs-auto-snapshot INTERVAL KEEP\n\n* INTERVAL - The interval for the snapshot. This is something such as `frequent`, `hourly`, `daily`, `weekly`, `monthly`, etc.\n* KEEP - How many to keep for this INTERVAL. Older ones will be destroyed.\n\n#### Crontab\n\n    15,30,45 * * * * root /usr/local/bin/zfs-auto-snapshot frequent  4\n    0        * * * * root /usr/local/bin/zfs-auto-snapshot hourly   24\n    7        0 * * * root /usr/local/bin/zfs-auto-snapshot daily     7\n    14       0 * * 7 root /usr/local/bin/zfs-auto-snapshot weekly    4\n    28       0 1 * * root /usr/local/bin/zfs-auto-snapshot monthly  12\n\n#### Dataset setup\n\nOnly datasets with the `com.sun:auto-snapshot` property set to `true` will be snapshotted.\n\n    zfs set com.sun:auto-snapshot=true DATASET\n\n##### MySQL Support\n\nSetting a MySQL dataset's property to `mysql` will hook it into the `zfs-snapshot-mysql` script. See its section for setup instructions.\n\n    zfs set com.sun:auto-snapshot=mysql DATASET\n\n##### PostgreSQL Support\n\nSetting a PostgreSQL dataset's property to `postgresql` will cause zfs-auto-snapshot to put postgresql in online backup mode for the snapshot.\n\n    zfs set com.sun:auto-snapshot=postgresql DATASET\n\nThe user executing `zfs-auto-snapshot` will require passwordless login to the `postgres` database and will require either REPLICATION or SUPERUSER privileges. The easiest approach is to set up a trust or ident record in your pg_hba.conf. The `zfs-auto-snapshot` script will execute pg_start_backup() prior to saving the snapshot and execute pg_stop_backup() afterwards. \n\n##### Overrides\n\nYou can override a child dataset to use, or not use auto snapshotting by settings its flag with the given interval.\n\n    zfs set com.sun:auto-snapshot:weekly=false DATASET\n\n### zfs-snapshot-mysql\n\nSnapshots a mysql server's databases. This requires that mysql's `datadir`/`innodb_data_home_dir`/`innodb_log_group_home_dir` be a ZFS dataset.\n\n#### Example MySQL+ZFS Setup\n\n##### Datasets\n\n    tank/db/mysql\n    tank/db/mysql/bin-log\n    tank/db/mysql/data\n    tank/db/mysql/innodb\n    tank/db/mysql/innodb/data\n    tank/db/mysql/innodb/log\n\n##### ZFS Settings\n\nThese settings should be set before importing any data.\n\n    zfs set primarycache=metadata tank/db/mysql/innodb\n    zfs set recordsize=16K tank/db/mysql/innodb/data\n    zfs set recordsize=8K tank/db/mysql/data\n    zfs set compression=lzjb tank/db/mysql/data\n\n##### MySQL Settings\n\n    innodb_data_home_dir = /tank/db/mysql/innodb/data\n    innodb_log_group_home_dir = /tank/db/mysql/innodb/log\n    datadir = /tank/db/mysql/data\n    log-bin = /tank/db/mysql/bin-log/mysql-bin\n\n#### Script Usage\n\nSetup a `/root/.my.cnf` with the relevant information on where to connect to, with the proper username/password that has access to `FLUSH LOGS` and `FLUSH TABLES WITH READ LOCK`.\nThe `zfs-auto-snapshot` script will automatically flush the tables before saving the snapshots.\n\n### zfs-cleanup-snapshots\n\nCleans up zero-sized snapshots. This ignores snapshots created by `zfs-auto-snapshot` as it handles zero-sized in its own special way.\n\n#### Usage\n\n#### Crontab\n\n    */20 * * * * /usr/local/bin/zfs-cleanup-snapshots\n","funding_links":[],"categories":["Ruby","ruby","🛠️ ZFS tools"],"sub_categories":["ZFS Backup tools"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbdrewery%2Fzfstools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbdrewery%2Fzfstools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbdrewery%2Fzfstools/lists"}