Browse Source

Symlink current added for backups

master
Dirk Alders 1 day ago
parent
commit
108a993532
1 changed files with 12 additions and 0 deletions
  1. 12
    0
      mysync

+ 12
- 0
mysync View File

3
 #
3
 #
4
 
4
 
5
 import config
5
 import config
6
+import errno
6
 import os
7
 import os
7
 import sys
8
 import sys
8
 import time
9
 import time
139
                 sys.stdout.write('\n' + 80 * '-' + '\n')
140
                 sys.stdout.write('\n' + 80 * '-' + '\n')
140
     if did_nothing:
141
     if did_nothing:
141
         help_msg()
142
         help_msg()
143
+    elif config.backup:
144
+        src = os.path.join(basepath, timestamp)
145
+        dst = os.path.join(basepath, 'current')
146
+        try:
147
+            os.symlink(src, dst)
148
+        except OSError as e:
149
+            if e.errno == errno.EEXIST:
150
+                os.remove(dst)
151
+                os.symlink(src, dst)
152
+            else:
153
+                raise e
142
 else:
154
 else:
143
     help_msg()
155
     help_msg()

Loading…
Cancel
Save