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.

snapshot.py 531B

4 years ago
123456789101112131415161718
  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. zfs_run(['zfs', 'snapshot', name + '@1'])