Thursday, September 10, 2015

PrestaShop /img dir Backup to S3

I have my PrestaShop code plus all my modifications saved in BitBucket and my database backups in S3 (I keep last 7 days, Monday from the last 5 weeks, monthly and yearly backups on S3). However, I didn't want to back up my PrestaShop /img dir in either of the above ways... I don't need img history, just an rsync of the /img folder to S3.

Searching for solutions led me to S3Tools and the like... open source or paid wrappers to bring S3 to the command line. I was more inclined to write something myself... I'm not real happy putting my S3 keys in programs like this.

Then I found AWS CLI from Amazon. It just works! I did a pip install, filled in my credentials, and 2 minutes later had a differential backup working from Linux to S3. Testing with changes, additions, and deletions all worked as expected.

Once tested, I added the below to my nightly cron backup script...

aws s3 sync /var/www/html/img s3://my_prestashop_bucket/img