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 thatcron
does not have all the path environment. Try adding the path to theaws
command in the script and see if works. Ifaws
callscp
you may need to add the path tocp
as well. This is just a guess. – user68186 Mar 17 '21 at 15:53aws
helped, you can post it as an answer. – jnemecz Mar 17 '21 at 15:58