diff --git a/bin/boto-rsync b/bin/boto-rsync index 76278b2..fde1c7e 100644 --- a/bin/boto-rsync +++ b/bin/boto-rsync @@ -209,6 +209,10 @@ def main(): help='Specify a specific S3 endpoint to connect to via boto\'s ' + \ '"host" connection argument (S3 only).' ) + parser.add_argument( + '--exclude', action='append', default=[], + help='Exclude files matching the specified pattern.' + ) parser.add_argument( '-g', '--grant', help='A canned ACL policy that will be granted on each file ' + \ @@ -313,6 +317,7 @@ def main(): cloud_secret_access_key = args.cloud_secret_access_key anon = args.anon endpoint = args.endpoint + exclude = args.exclude grant = args.grant metadata = args.metadata if not isinstance(metadata, dict): @@ -542,6 +547,22 @@ def main(): key_name = cloud_path + get_key_name(fullpath, path) file_size = os.path.getsize(fullpath) + # determine if the file should be excluded according to command line arguments. + excludeFile = False + for excludePath in exclude: + if fullpath.startswith(excludePath): + excludeFile = True + continue + elif fullpath[len(path):].lstrip(os.sep).startswith(excludePath): + excludeFile = True + continue + if excludeFile: + sys.stdout.write( + 'Skipping %s (excluded path)\n' % + fullpath[len(path):].lstrip(os.sep) + ) + continue + if file_size == 0: if ignore_empty: if not quiet: