{"action":"created","issue":{"url":"https://api.github.com/repos/jimsalterjrs/sanoid/issues/193","repository_url":"https://api.github.com/repos/jimsalterjrs/sanoid","labels_url":"https://api.github.com/repos/jimsalterjrs/sanoid/issues/193/labels{/name}","comments_url":"https://api.github.com/repos/jimsalterjrs/sanoid/issues/193/comments","events_url":"https://api.github.com/repos/jimsalterjrs/sanoid/issues/193/events","html_url":"https://github.com/jimsalterjrs/sanoid/pull/193","id":288331429,"node_id":"MDExOlB1bGxSZXF1ZXN0MTYyNzgxMzM3","number":193,"title":"Add pre and post snapshot scripts","user":{"login":"jouir","id":24910974,"node_id":"MDQ6VXNlcjI0OTEwOTc0","avatar_url":"https://avatars3.githubusercontent.com/u/24910974?v=4","gravatar_id":"","url":"https://api.github.com/users/jouir","html_url":"https://github.com/jouir","followers_url":"https://api.github.com/users/jouir/followers","following_url":"https://api.github.com/users/jouir/following{/other_user}","gists_url":"https://api.github.com/users/jouir/gists{/gist_id}","starred_url":"https://api.github.com/users/jouir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jouir/subscriptions","organizations_url":"https://api.github.com/users/jouir/orgs","repos_url":"https://api.github.com/users/jouir/repos","events_url":"https://api.github.com/users/jouir/events{/privacy}","received_events_url":"https://api.github.com/users/jouir/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2018-01-13T14:01:36Z","updated_at":"2018-10-02T08:28:54Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/jimsalterjrs/sanoid/pulls/193","html_url":"https://github.com/jimsalterjrs/sanoid/pull/193","diff_url":"https://github.com/jimsalterjrs/sanoid/pull/193.diff","patch_url":"https://github.com/jimsalterjrs/sanoid/pull/193.patch"},"body":"Execute scripts before and after snapshot creation (#105).\r\n\r\nExample with the following datasets:\r\n```\r\n# zfs list -o name -H\r\nzfspool\r\nzfspool/containers\r\nzfspool/containers/dbserver\r\nzfspool/containers/webserver\r\n```\r\nFile `/etc/sanoid/sanoid.conf`:\r\n```\r\n[zfspool/containers]\r\n\tuse_template = containers\r\n\trecursive = yes\r\n\tprocess_children_only = yes\r\n\tprescript = /opt/scripts/prescript.sh\r\n\tpostscript = /opt/scripts/postscript.sh\r\n\r\n[template_containers]\r\n\tautosnap = yes\r\n\tautoprune = yes\r\n\thourly = 0\r\n\tdaily = 30\r\n\tmonthly = 0\r\n\tyearly = 0\r\n```\r\nScripts:\r\n```\r\n# ls -l /opt/scripts/prescript.sh /opt/scripts/postscript.sh \r\n-rwxr--r-- 1 root root 113 Jan 13 12:56 /opt/scripts/postscript.sh\r\n-rwxr--r-- 1 root root 113 Jan 13 12:56 /opt/scripts/prescript.sh\r\n```\r\nScript example:\r\n```bash\r\n#!/bin/bash\r\nif [ $# != 1 ] ; then\r\n    echo \"Usage: $0 <snapshot>\"\r\n    exit 1\r\nfi\r\n\r\nSNAPSHOT=$1\r\n\r\n# Do stuff\r\nexit 0\r\n```\r\nExecution:\r\n```\r\n# ./sanoid --verbose --take-snapshots\r\nINFO: cache expired - updating from zfs list.\r\nINFO: taking snapshots...\r\nexecuting prescript '/opt/scripts/prescript.sh zfspool/containers/dbserver@autosnap_2018-01-13_13:55:44_daily'\r\ntaking snapshot zfspool/containers/dbserver@autosnap_2018-01-13_13:55:44_daily\r\nexecuting postscript '/opt/scripts/postscript.sh zfspool/containers/dbserver@autosnap_2018-01-13_13:55:44_daily'\r\nexecuting prescript '/opt/scripts/prescript.sh zfspool/containers/webserver@autosnap_2018-01-13_13:55:44_daily'\r\ntaking snapshot zfspool/containers/webserver@autosnap_2018-01-13_13:55:44_daily\r\nexecuting postscript '/opt/scripts/postscript.sh zfspool/containers/webserver@autosnap_2018-01-13_13:55:44_daily'\r\nINFO: cache expired - updating from zfs list.\r\n```\r\nSnapshot created with pre and post scripts:\r\n```\r\n# zfs list -t all -o name -H\r\nzfspool\r\nzfspool/containers\r\nzfspool/containers/dbserver\r\nzfspool/containers/dbserver@autosnap_2018-01-13_13:55:44_daily\r\nzfspool/containers/webserver\r\nzfspool/containers/webserver@autosnap_2018-01-13_13:55:44_daily\r\n```\r\nIt can be handy for some database services where service must be down before creating the snapshot to make it consistent."},"comment":{"url":"https://api.github.com/repos/jimsalterjrs/sanoid/issues/comments/426191863","html_url":"https://github.com/jimsalterjrs/sanoid/pull/193#issuecomment-426191863","issue_url":"https://api.github.com/repos/jimsalterjrs/sanoid/issues/193","id":426191863,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNjE5MTg2Mw==","user":{"login":"darkbasic","id":1047358,"node_id":"MDQ6VXNlcjEwNDczNTg=","avatar_url":"https://avatars1.githubusercontent.com/u/1047358?v=4","gravatar_id":"","url":"https://api.github.com/users/darkbasic","html_url":"https://github.com/darkbasic","followers_url":"https://api.github.com/users/darkbasic/followers","following_url":"https://api.github.com/users/darkbasic/following{/other_user}","gists_url":"https://api.github.com/users/darkbasic/gists{/gist_id}","starred_url":"https://api.github.com/users/darkbasic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/darkbasic/subscriptions","organizations_url":"https://api.github.com/users/darkbasic/orgs","repos_url":"https://api.github.com/users/darkbasic/repos","events_url":"https://api.github.com/users/darkbasic/events{/privacy}","received_events_url":"https://api.github.com/users/darkbasic/received_events","type":"User","site_admin":false},"created_at":"2018-10-02T08:28:54Z","updated_at":"2018-10-02T08:28:54Z","author_association":"NONE","body":"I've tried it, the branch works flawlessly. Unfortunately it doesn't expose the snapshot name, which is something I really need.\r\n@jouir \tI opened a PR to expose the snapshot name through ENV variable: https://github.com/jouir/sanoid/pull/1"}}
{"actor":{"display_login":"darkbasic"}}