Attached is a new version of my
s3 perl command line script to access S3 and a new
s3sync perl script that has rsync-like functionality.
s3sync uses the
s3 script and you need to set the path to that script properly at the beginning of the
s3sync script.
s3sync -h prints out help information. I highly recommend the
-n flag to get comfortable with what it does! Here's the help:
#usage:
# s3sync [options] <src> <bucket>:<prefix>
- s3sync [options] <bucket>:<prefix> <dst>
- -h: print help
- -d: print debug info
- -r: recursive
- -s: use secure (HTTPS) connection (default HTTP)
- -n: dry-run - don't put/get anything, just print what would be done
#
#S3 object naming:
# A local src named /foo/bar/baz.ext is stored with key foo/bar/baz.ext
- A local src named foo/bar/baz.ext is stored with key foo/bar/baz.ext
- This is intended to be identical to rsync's behavior if your remote
- home directory were / except that keys in S3 don't start with a /
Some simple sample usage:
dev aws # ls -R NM-October-00/20001003/
NM-October-00/20001003/:
20001003-083749.jpg 20001003-150357.jpg
20001003-150223.jpg 20001003-150650.jpg
dev aws # ./s3sync -n NM-October-00/20001003 tve-test:/img
NM-October-00/20001003/20001003-083749.jpg -> tve-test:img/20001003/20001003-083749.jpg
NM-October-00/20001003/20001003-150223.jpg -> tve-test:img/20001003/20001003-150223.jpg
NM-October-00/20001003/20001003-150357.jpg -> tve-test:img/20001003/20001003-150357.jpg
NM-October-00/20001003/20001003-150650.jpg -> tve-test:img/20001003/20001003-150650.jpg
dev aws # ./s3sync -n NM-October-00/20001003/ tve-test:/img
NM-October-00/20001003/20001003-083749.jpg -> tve-test:img/20001003-083749.jpg
NM-October-00/20001003/20001003-150223.jpg -> tve-test:img/20001003-150223.jpg
NM-October-00/20001003/20001003-150357.jpg -> tve-test:img/20001003-150357.jpg
NM-October-00/20001003/20001003-150650.jpg -> tve-test:img/20001003-150650.jpg
dev aws # # notice trailing slash in source path..
dev aws # ./s3sync NM-October-00/20001003/ tve-test:/img
dev aws # # took a loong time to transfer...
dev aws # ./s3sync -d NM-October-00/20001003/ tve-test:/img
load_etags command: ./s3 -l ls 'tve-test' 'img'
img/20001003-083749.jpg -> 255018 -- 02052099847a6ff3c268eda97582a1c5
img/20001003-150223.jpg -> 240357 -- ac485ce64c3075ef245ed2cdf2337f80
img/20001003-150357.jpg -> 243913 -- 9b6d7e24e20763d7f2d65ffab13447f5
img/20001003-150650.jpg -> 140159 -- ef6b362054b112a3905121f36a288b7d
Putting directory NM-October-00/20001003 to img
skip dir .
skip dir ..
put file NM-October-00/20001003/20001003-083749.jpg -> img/20001003-083749.jpg
sizes match, checking md5/etag
md5/etag match - skipping put
put file NM-October-00/20001003/20001003-150223.jpg -> img/20001003-150223.jpg
sizes match, checking md5/etag
md5/etag match - skipping put
put file NM-October-00/20001003/20001003-150357.jpg -> img/20001003-150357.jpg
sizes match, checking md5/etag
md5/etag match - skipping put
put file NM-October-00/20001003/20001003-150650.jpg -> img/20001003-150650.jpg
sizes match, checking md5/etag
md5/etag match - skipping put
dev aws # # this was real fast since the files were already there
dev aws # ./s3 ls tve-test img
img/20001003-083749.jpg
img/20001003-150223.jpg
img/20001003-150357.jpg
img/20001003-150650.jpg
dev aws # ./s3sync -n tve-test:img/ images
mkdir images
tve-test:img/20001003-150650.jpg -> images/20001003-150650.jpg
tve-test:img/20001003-150357.jpg -> images/20001003-150357.jpg
tve-test:img/20001003-083749.jpg -> images/20001003-083749.jpg
tve-test:img/20001003-150223.jpg -> images/20001003-150223.jpg
dev aws # ./s3sync tve-test:img/ images
dev aws # # took a while to fech all the files...
dev aws # du images
888 images
dev aws # diff -r images NM-October-00/20001003
-Thorsten