Migrating local media files to Amazon S3

Yesterday, my lead decide to using Amazon S3 to store all static and media files because our project will run on several instance. For django integration there is some package that very easy to use called django-storages. At glance this package will automatically store all your FileField and ImageField into Amazon S3.

But the problem is, my current project is already had initial data, so on the live server it will not working, because all the media urls pointed to Amazon S3 and the current data, media files still on live server. So I have to migrating all of those files to Amazon S3.

To do this, I found boto-rsync for dealing with this kind of problem. But on the github page, the creator stated that this package is already deprecated, and he suggest to using awscli instead. I’m not using awscli because it’s a lil bit complicated rather than boto-rsync that we can sync our media files just in one line command. I’m trying boto-rsync and this package still working without any trouble. My problem solved just executing this single line of command.

$ boto-rsync -a access_key -s secret_key  your/local/media/path/ s3://bucket_name/target/path/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.