Symlink current added for backups

This commit is contained in:
Dirk Alders 2025-01-09 19:09:53 +01:00
parent be3dda31de
commit 108a993532

12
mysync
View File

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