I have shell script executed by cron.
*/5 * * * * /home/foo/backups/backup.sh
An backup script:
#!/bin/bash
FILE_NAME=$(date +%Y%m%d%H%M)
PATH1="/home/foo/backups/data-$FILE_NAME.sql.gz"
pg_dump -U XXX -E utf8 --no-acl -h localhost --no-owner XXX | gzip -c > $PATH1
aws s3 cp $PATH1 s3://XXX
Cron is executed correctly and local backup is created. But dump file is not copied to Amazon S3 bucket. When I run /home/foo/backups/backup.sh manually, file is transfered to S3.
Is there any reason why S3 cli could not work when aws s3 cp is executed from cron?
aws, but I know thatcrondoes not have all the path environment. Try adding the path to theawscommand in the script and see if works. Ifawscallscpyou may need to add the path tocpas well. This is just a guess. – user68186 Mar 17 '21 at 15:53awshelped, you can post it as an answer. – jnemecz Mar 17 '21 at 15:58