Amiclone
Amiclone

Reputation: 408

Syncing of S3 to local directory in Python

I am trying to sync S3 bucket:

 s3://xxxxxxxx-data/ds_2/accounts/xxxxxx

to my local:

/abc/def

in Python 3. Could someone please suggest me how to do it?

I am not able to figure out this on the basis of current questions available. Thanks in advance

Upvotes: 13

Views: 10477

Answers (2)

Adi Dembak
Adi Dembak

Reputation: 2546

You could call the s3 sync command from python with os.system:

import os

cmd = 'aws s3 sync s3://source-bucket/ my-dir'
os.system(cmd)

Upvotes: 9

Marcin
Marcin

Reputation: 238727

There is no s3 sync feature in boto3 as there is in AWS CLI. There are open issues for that though:

So hopeful, one day they will be implemented.

In the issues you can find code snippets of functions others made to get similar functionality. There are also plenty of similar code in other places.

Upvotes: 6

Related Questions