First create an Iam user and use the below poicy. 

{

    "Version": "2012-10-17",

    "Statement": [

        {

            "Effect": "Allow",

            "Action": [

                "s3:ListBucket",

                "s3:ListAllMyBuckets",

                "s3:GetBucketLocation"

            ],

            "Resource": [

                "arn:aws:s3:::BUCKET-NAME"

            ]

        },

        {

            "Effect": "Allow",

            "Action": [

                "s3:PutObject",

                "s3:GetObject",

                "s3:DeleteObject"

            ],

            "Resource": [

                "arn:aws:s3:::BUCKET-NAME/*"

            ]

        }

    ]

}

Make sure to change the bucket names in the new policy.

 

Use these commands to install s3cmd:

https://levels.io/backup-linode-digital-ocean-vps-amazon-s3/

sudo wget -O- -q http://s3tools.org/repo/deb-all/stable/s3tools.key | sudo apt-key add -

sudo wget http://s3tools.org/repo/deb-all/stable/s3tools.list -O /etc/apt/sources.list.d/s3tools.list

sudo apt-get update && apt-get install s3cmd

sudo s3cmd --configure

 

Next create a cron job:

0 3 * * * s3cmd sync --recursive --preserve /srv/users/serverpilot/apps s3://BUCKET-NAME/