How to manually migrate all files from S3 back to EC2 Server?

Finally, I think I find a solution to my problem. I think I have solved 95% of the problem. I am not sure if its the best way to do it.

./launcher enter app
sudo apt install awscli
aws configure

Configured aws with my S3 ID and password. then

cd public/uploads/default/
aws s3 sync s3://mybucketname/

This command downloaded all the three directories with all the files from S3. Since I can’t find the folder named inventory anywhere in my previous server, I deleted it (Not sure about deleting this folder). Then

rake posts:rebake
exit
./launcer rebuild app

Bam, everything started working again as normal. But I find image links in one of the post is broken, but if edited I can view the image in the editor. I download the same image and tried to upload it again, but still the broken image. Not sure if its a separate problem or it’s related to the current problem.