|
|
|
@ -199,7 +199,7 @@ async def snapshot_creation_task(schedule, fs): |
|
|
|
|
serial = make_snapshot_serial() |
|
|
|
|
recursive = schedule['recursive'] |
|
|
|
|
|
|
|
|
|
if get_fs_flag(fs, tag): |
|
|
|
|
if not schedule['if_modified'] or get_fs_flag(fs, tag): |
|
|
|
|
# Clear tag-modified flags for this tag on filesystem |
|
|
|
|
clear_fs_flag(fs, tag) |
|
|
|
|
|
|
|
|
@ -239,13 +239,21 @@ def snapshot_matches_tag(snapshot, tag): |
|
|
|
|
|
|
|
|
|
# Get tag of snapshot |
|
|
|
|
def get_snapshot_tag(snapshot): |
|
|
|
|
(tag, serial) = get_snapshot_fields(snapshot) |
|
|
|
|
return tag |
|
|
|
|
fields = get_snapshot_fields(snapshot) |
|
|
|
|
if len(fields) == 2: |
|
|
|
|
(tag, serial) = fields |
|
|
|
|
return tag |
|
|
|
|
else: |
|
|
|
|
return '' |
|
|
|
|
|
|
|
|
|
# Get serial number of snapshot |
|
|
|
|
def get_snapshot_serial(snapshot): |
|
|
|
|
(tag, serial) = get_snapshot_fields(snapshot) |
|
|
|
|
return serial |
|
|
|
|
fields = get_snapshot_fields(snapshot) |
|
|
|
|
if len(fields) == 2: |
|
|
|
|
(tag, serial) = fields |
|
|
|
|
return serial |
|
|
|
|
else: |
|
|
|
|
return '' |
|
|
|
|
|
|
|
|
|
# Get tuple of fields in snapshot name |
|
|
|
|
def get_snapshot_fields(snapshot): |
|
|
|
@ -302,18 +310,24 @@ def load_snapshot_schedules(): |
|
|
|
|
|
|
|
|
|
async def main_task(): |
|
|
|
|
global config, event_loop, scheduler, fs_listeners |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scheduler = AsyncIOPriorityScheduler( |
|
|
|
|
event_loop = event_loop, |
|
|
|
|
executors = {'default': AsyncIOPriorityExecutor()}) |
|
|
|
|
|
|
|
|
|
monitor = False |
|
|
|
|
for schedule in get_schedules(): |
|
|
|
|
if schedule['if_modified']: |
|
|
|
|
monitor = True |
|
|
|
|
|
|
|
|
|
# Watch file system mountpoints |
|
|
|
|
fs_listeners = dict() |
|
|
|
|
for fs in zfs_get_filesystems(): |
|
|
|
|
await event_loop.subprocess_exec( |
|
|
|
|
lambda: FSWatchProtocol(fs), config['fswatch_path'], '-o', fs['mountpoint'], stdout=PIPE) |
|
|
|
|
|
|
|
|
|
if monitor: |
|
|
|
|
logger.info('Starting file system watcher') |
|
|
|
|
fs_listeners = dict() |
|
|
|
|
for fs in zfs_get_filesystems(): |
|
|
|
|
await event_loop.subprocess_exec( |
|
|
|
|
lambda: FSWatchProtocol(fs), config['fswatch_path'], '-o', fs['mountpoint'], stdout=PIPE) |
|
|
|
|
|
|
|
|
|
load_snapshot_schedules() |
|
|
|
|
|
|
|
|
|
scheduler.start() |
|
|
|
|