From 108a993532721b32e5d4909f53a35f4d8c9685fd Mon Sep 17 00:00:00 2001 From: Dirk Alders Date: Thu, 9 Jan 2025 19:09:53 +0100 Subject: [PATCH] Symlink current added for backups --- mysync | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/mysync b/mysync index ec8fcee..75df3af 100755 --- a/mysync +++ b/mysync @@ -3,6 +3,7 @@ # import config +import errno import os import sys import time @@ -139,5 +140,16 @@ if __name__ == '__main__': sys.stdout.write('\n' + 80 * '-' + '\n') if did_nothing: help_msg() + elif config.backup: + src = os.path.join(basepath, timestamp) + dst = os.path.join(basepath, 'current') + try: + os.symlink(src, dst) + except OSError as e: + if e.errno == errno.EEXIST: + os.remove(dst) + os.symlink(src, dst) + else: + raise e else: help_msg()