def isMatchingTime(task, snaptime): curtime = time(snaptime.hour, snaptime.minute) repeat_type = task.task_repeat_unit if not isTimeBetween(curtime, task.task_begin, task.task_end): return False if repeat_type == 'daily': return True if repeat_type == 'weekly': cur_weekday = snaptime.weekday() + 1 if ('%d' % cur_weekday) in task.task_byweekday.split(','): return True return False
def isMatchingTime(task, snaptime): curtime = time(snaptime.hour, snaptime.minute) repeat_type = task.task_repeat_unit if not isTimeBetween(curtime, task.task_begin, task.task_end): return False if repeat_type == "daily": return True if repeat_type == "weekly": cur_weekday = snaptime.weekday() + 1 if ("%d" % cur_weekday) in eval(task.task_byweekday): return True return False
exit_if_running(AUTOREPL_PID) with open('/var/run/autorepl.pid', 'w') as pidfile: pidfile.write('%d' % mypid) MNTLOCK.unlock() # At this point, we are sure that only one autorepl instance is running. log.debug("Autosnap replication started") log.debug("temp log file: %s" % (templog, )) # Traverse all replication tasks replication_tasks = Replication.objects.all() for replication in replication_tasks: if not isTimeBetween(now, replication.repl_begin, replication.repl_end): continue if not replication.repl_enabled: log.warn("%s replication not enabled" % replication) continue remote = replication.repl_remote.ssh_remote_hostname.__str__() remote_port = replication.repl_remote.ssh_remote_port dedicateduser = replication.repl_remote.ssh_remote_dedicateduser fast_cipher = replication.repl_remote.ssh_fast_cipher remotefs = replication.repl_zfs.__str__() localfs = replication.repl_filesystem.__str__() last_snapshot = replication.repl_lastsnapshot.__str__() resetonce = replication.repl_resetonce
replication.id, exc_info=True) continue with open("/tmp/.repl-key", "w") as f: f.write(keys["private_key"] + "\n") os.chmod("/tmp/.repl-key", 0o400) with open("/tmp/.repl-key.pub", "w") as f: f.write(keys["public_key"] + "\n") os.chmod("/tmp/.repl-key.pub", 0o400) with open("/usr/local/etc/ssh/ssh_known_hosts", "w") as f: f.write(replication.repl_remote_hostkey) # END REPLICATION ADAPTER if not isTimeBetween(now, replication.repl_begin, replication.repl_end): continue if not replication.repl_enabled: log.debug("%s replication not enabled" % replication) continue remote = replication.repl_remote.ssh_remote_hostname.__str__() remote_port = replication.repl_remote.ssh_remote_port dedicateduser = replication.repl_remote.ssh_remote_dedicateduser cipher = replication.repl_remote.ssh_cipher remotefs = replication.repl_zfs.__str__() localfs = replication.repl_filesystem.__str__() compression = replication.repl_compression.__str__() followdelete = not not replication.repl_followdelete recursive = not not replication.repl_userepl