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/