git » abk » commit 674487a

New 'sync' command interface.

author Leandro Lucarella
2005-03-04 19:40:27 UTC
committer Leandro Lucarella
2005-03-04 19:40:27 UTC
parent 71d520683c4f6f133901e21e3166a8249d2f68ab

New 'sync' command interface.
New interface: abk sync idx src dst
The new sync command interface overwrites the destination index with the
source one, unless you use the --new-idx option, to save the source index
somewhere else.

abk +12 -7

diff --git a/abk b/abk
index 9357610..ce54772 100644
--- a/abk
+++ b/abk
@@ -452,8 +452,8 @@ commands:
     shows the given index file contents
   mkidx idx_file dir
     builds an index file for the given directory
-  sync src src.idx dst dst.idx
-    synchronizes src with dst, using the given index files"""
+  sync idx src dst
+    synchronizes src with dst, using the given idx index file"""
 	parser = AbkOptionParser(usage=usage, description="A backup script - "
 		"Alberto Bertogli (albertogli@telpin.com.ar)",
 		version="%prog " + VERSION, prog='abk')
@@ -469,6 +469,10 @@ commands:
 	parser.add_option("-a", "--hash-mode", default='sha', metavar="MODE",
 		help="select the hash to use to check for file content change. "
 		"Available modes: none, sha, md5 [default: sha]")
+	parser.add_option("-i", "--new-idx", metavar="FILE",
+		help="select where to write the new generated index. "
+		"This is useful for incremental backups. "
+		"If not specified, the old index file (idx) is overwritten")
 	(opts, args) = parser.parse_args()
 	return (parser, opts, args)
 
@@ -520,14 +524,15 @@ elif cmd == 'mkidx':
 	build_idx(idx_path, path)
 elif cmd == 'sync':
 	try:
-		src_path = args[1]
-		srcidx_path = args[2]
+		old_idx_path = args[1]
+		new_idx_path = old_idx_path
+		src_path = args[2]
 		dst_path = args[3]
-		dstidx_path = args[4]
 	except:
 		parser.error("Missing parameter(s) for command sync.")
-	
-	make_sync(src_path, srcidx_path, dst_path, dstidx_path)
+	if opts.new_idx:
+		new_idx_path = opts.new_idx
+	make_sync(src_path, new_idx_path, dst_path, old_idx_path)
 else:
 	parser.error("Unknown command (%s)." % cmd)