Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to automatically sync s3 bucket to a local folder

Im trying to have a replica of my s3 bucket in a local folder. it should be updated when a change occurs on the bucket. I see many options to do it using lambda functions but im asking about the usage of s3 cli command:

aws s3 sync s3://my-bucket . --delete

which will download any files exists on the bucket, and also delete local files that exists locally but missing from the bucket (expected behavior).

Is there any problem to loop it forever with few sec of delay, like?

while true; do aws s3 sync s3://my-bucket . --delete; sleep 3s; done

Is there any limitation of the number of api calls i can do per second ? is there a better solution ?

like image 769
chenchuk Avatar asked Nov 07 '22 09:11

chenchuk


1 Answers

Are you on linux? You could stick your command in a shell script and run it as a cronjob

* * * * * /path/to/your/script

^ Runs every minute

*/10 * * * * /path/to/your/script

^ Runs every 10 minutes

That would be much more reliable than a bash script in a loop.

like image 116
F_SO_K Avatar answered Nov 15 '22 06:11

F_SO_K