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,6 +3,7 @@
3 3
 #
4 4
 
5 5
 import config
6
+import errno
6 7
 import os
7 8
 import sys
8 9
 import time
@@ -139,5 +140,16 @@ if __name__ == '__main__':
139 140
                 sys.stdout.write('\n' + 80 * '-' + '\n')
140 141
     if did_nothing:
141 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 154
 else:
143 155
     help_msg()

Loading…
Cancel
Save