Ronny Pfannschmidt avatar Ronny Pfannschmidt committed 13a9536

factor out the syncing

Comments (0)

Files changed (1)

 parser.add_argument('--show', action='store_true')
 parser.add_argument('--sync', default=[], action='append')
 parser.add_argument('--ls')
+parser.add_argument('--archive', nargs=2)
+parser.add_argument('--extract', nargs=2)
+
 
 from bmst.backup_app import make_backup
 from bmst.managed import BMST, check_bmst, dumb_sync
     print('using store', opts.store)
     bmst = get_bmst(opts.store)
 
-    for source in opts.sync:
-        print('pulling from', source)
-        other = get_bmst(source)
-        dumb_sync(source=other.meta, target=bmst.meta)
-        dumb_sync(source=other.blobs, target=bmst.blobs)
+
+    if opts.sync:
+        sync(bmst, opts.sync)
 
     if opts.check:
         check_bmst(bmst)
 
+
     for to_backup in opts.backup:
         path = py.path.local(to_backup)
         make_backup(root=path, bmst=bmst)
         meta = FileStore(root.ensure('meta', dir=1))
         blobs = FileStore(root.ensure('blobs', dir=1))
     return BMST(meta=meta, blobs=blobs)
+
+
+def sync(target, sources):
+    for source in sources:
+        print('pulling from', source)
+        other = get_bmst(source)
+        dumb_sync(source=other.meta, target=target.meta)
+        dumb_sync(source=other.blobs, target=target.blobs)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.