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
599B

  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. zfs_run(['zfs', 'set', 'readonly=on', name])
  13. snap_name = name + '@1'
  14. zfs_run(['zfs', 'snapshot', snap_name])
  15. except:
  16. zfs_run(['zfs', 'destroy', '-f', name])
  17. raise
  18. return snap_name