crontool
Paste a schedule, read it in English, see the next runs.

Back Up to S3 Daily with Cron

To upload a backup to S3 every night, call the AWS CLI from cron. A common choice is 3 AM: 0 3 * * *.

The command

0 3 * * * /usr/local/bin/aws s3 cp /backups/db.sql.gz s3://my-bucket/db/ >> /var/log/s3backup.log 2>&1

Use the full path to aws — cron's PATH is minimal and often can't find it. Run which aws to get the path.

Sync a whole folder

0 3 * * * /usr/local/bin/aws s3 sync /var/backups s3://my-bucket/backups --delete

Credentials

Cron doesn't load your shell profile, so ~/.aws/credentials for the cron user must exist, or set AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY above the line (or use an IAM instance role on EC2).

FAQ

How do I back up to S3 from cron?

Call the AWS CLI with a full path: 0 3 * * * /usr/local/bin/aws s3 cp /backups/db.sql.gz s3://bucket/db/. Log output with >> file 2>&1.

Why does aws s3 fail only under cron?

Cron's PATH is minimal, so it can't find aws by name. Use the full path (which aws) and make sure ~/.aws/credentials exists for the cron user.

How do I sync a whole directory to S3?

Use aws s3 sync /local/dir s3://bucket/path --delete to mirror the folder, removing files in S3 that no longer exist locally.