Search code examples
ruby-on-railsamazon-s3s3cmd

Automatic backup from s3 to another server or cloud


I am using s3cmd to backup my files from s3, I run the following command from my terminal to sync between my files in my_bucket and my local folder called workfiles which is in the home directory

s3cmd sync s3://my_bucket/ /home/mody/workfiles/ --delete-removed

This is a manual method and it will be painful if the volume is big, so I am wondering if it's possible to do some kind of automatic backup to a server like digitalocean or some other cloud service, and how to do that ? any code snippet will be appreciated! Thanks


Solution

  • As per our discussion, you may setup a cronjob to schedule tasks on your local/remote server. Different linux distributions might have different crontab files setup for you. For example, according to this article, DigitalOcean has hourly, daily, etc. crontab folders setup for your convenience for their Ubuntu instances.

    So, you can create a file with your command to execute in /etc/cron.daily folder:

    s3cmd sync s3://my_bucket/ /path/to/backupfolder/ --delete-removed
    

    Make sure to install s3tools on your remote machine as well.