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
25 changes: 25 additions & 0 deletions bin/boto-rsync
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import sys, os, time, datetime, argparse, threading, signal
from fnmatch import fnmatch
import boto
import re

__version__ = '0.8.1'

Expand Down Expand Up @@ -209,6 +210,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 +318,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 +548,25 @@ 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):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is probably error-prone as it matches all directories that start with (but do not match exactly) the given exclude pattern

excludeFile = True
continue
elif fullpath[len(path):].lstrip(os.sep).startswith(excludePath):
excludeFile = True
continue
elif re.search(excludePath, file):
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