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()