IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an email to s dot adaszewski at gmail dot com. User accounts are meant only to report issues and/or generate pull requests. This is a purpose-specific Git hosting for ADARED projects. Thank you for your understanding!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
581B

  1. from .zfs import *
  2. def new_snapshot(base, fun, name):
  3. type_ = zfs_get_type(base)
  4. if type_ != 'snapshot':
  5. raise ValueError('Provided base dataset is not a snapshot')
  6. if '/' not in name:
  7. root = '/'.join(base.split('/')[:-1])
  8. name = root + '/' + name
  9. zfs_run(['zfs', 'clone', base, name])
  10. try:
  11. fun()
  12. except:
  13. zfs_run(['zfs', 'destroy', name])
  14. raise
  15. zfs_run(['zfs', 'set', 'readonly=on', name])
  16. snap_name = name + '@1'
  17. zfs_run(['zfs', 'snapshot', snap_name])
  18. return snap_name