Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions bin/boto-rsync
Original file line number Diff line number Diff line change
Expand Up @@ -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 ' + \
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand Down