adding support for filtering via whitelist with -inc
authorEduardo Robles Elvira <edulix@wadobo.com>
Fri, 18 Oct 2013 10:08:04 +0000 (12:08 +0200)
committerEduardo Robles Elvira <edulix@wadobo.com>
Fri, 18 Oct 2013 10:08:04 +0000 (12:08 +0200)
backup.py

index 41deb77..d15743d 100644 (file)
--- a/backup.py
+++ b/backup.py
@@ -69,6 +69,10 @@ if __name__ == "__main__":
     parser.add_argument("-l", "--list-files", action='store_true', help="List files in a tarball")
     parser.add_argument("-x", "--excluded", nargs='+', default=[],
                         help="excluded files")
+    parser.add_argument("-inc", "--included", nargs='+', default=[],
+                        help="included files")
+    parser.add_argument("-ip", "--included-path", default=None,
+                        help="path to the file containing included paths")
     parser.add_argument("-xp", "--excluded-path", default=None,
                         help="path to the file containing excluded paths")
     parser.add_argument("-e", "--equals", action='store_true', help="Checks two dirs are equal")
@@ -82,8 +86,16 @@ if __name__ == "__main__":
     else:
         excluded_files = args.excluded
 
+    if args.included_path:
+        f = open(args.included_path, 'r')
+        included_files = f.readlines()
+        f.close()
+    else:
+        included_files = args.included
+
     deltatar = DeltaTar(mode=args.mode, password=args.password,
-        logger=consoleLogger, excluded_files=excluded_files)
+        logger=consoleLogger, excluded_files=excluded_files,
+        included_files=included_files)
 
     if args.full:
         deltatar.create_full_backup(args.sourcepath, args.targetpath, args.volsize)