Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-creating Bookmarks as well? #89

Open
sjau opened this issue Jul 6, 2018 · 2 comments
Open

Auto-creating Bookmarks as well? #89

sjau opened this issue Jul 6, 2018 · 2 comments

Comments

@sjau
Copy link

sjau commented Jul 6, 2018

I think it would be good if you could tell zfs auto snapshot to also auto-create bookmarks for the created snapshots.

@mailinglists35
Copy link
Contributor

this can be done with a small modification to the script:

diff -p  zfs-auto-snapshot-master/src/zfs-auto-snapshot.sh zfs-auto-snapshot-master+bookmark/src/zfs-auto-snapshot.sh
*** zfs-auto-snapshot-master/src/zfs-auto-snapshot.sh   2019-09-30 10:30:55.000000000 +0300
--- zfs-auto-snapshot-master+bookmark/src/zfs-auto-snapshot.sh        2022-06-19 14:43:55.719638308 +0300
*************** opt_pre_snapshot=''
*** 43,48 ****
--- 43,49 ----
  opt_post_snapshot=''
  opt_do_snapshots=1
  opt_min_size=0
+ opt_bookmark=''

  # Global summary statistics.
  DESTRUCTION_COUNT='0'
*************** do_snapshots () # properties, flags, sna
*** 187,192 ****
--- 188,194 ----
                        if [ $RUNSNAP -eq 1 ] && do_run "zfs snapshot $PROPS $FLAGS '$ii@$NAME'"
                        then
                                [ "$opt_post_snapshot" != "" ] && do_run "$opt_post_snapshot $ii $NAME"
+                                 [ "$opt_bookmark" != "" ] && do_run "zfs bookmark '$ii@$NAME' '$ii#$NAME'"
                                SNAPSHOT_COUNT=$(( $SNAPSHOT_COUNT + 1 ))
                        else
                                WARNING_COUNT=$(( $WARNING_COUNT + 1 ))
*************** GETOPT=$($GETOPT_BIN \
*** 235,241 ****
    --longoptions=event:,keep:,label:,prefix:,sep: \
    --longoptions=debug,help,quiet,syslog,verbose \
    --longoptions=pre-snapshot:,post-snapshot:,destroy-only \
!   --longoptions=min-size: \
    --options=dnshe:l:k:p:rs:qgvm: \
    -- "$@" ) \
    || exit 128
--- 237,243 ----
    --longoptions=event:,keep:,label:,prefix:,sep: \
    --longoptions=debug,help,quiet,syslog,verbose \
    --longoptions=pre-snapshot:,post-snapshot:,destroy-only \
!   --longoptions=min-size:,bookmark \
    --options=dnshe:l:k:p:rs:qgvm: \
    -- "$@" ) \
    || exit 128
*************** do
*** 362,367 ****
--- 364,373 ----
                        opt_do_snapshots=''
                        shift 1
                        ;;
+                 (--bookmark)
+                         opt_bookmark=1
+                         shift 1
+                         ;;
                (--)
                        shift 1
                        break

@mailinglists35
Copy link
Contributor

mailinglists35 commented Jun 19, 2022

+ my cron modification:

[ $(ps axfww|grep D|grep zpool|grep -v grep|wc -l) -gt 0 ] || exec zfs-auto-snapshot --bookmark --quiet --syslog --label=hourly --keep=24 --fast --default-exclude --min-size=1 //

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@sjau @mailinglists35 and others