0

I have the following script that saves a db backup to s3:

# next, backup the mysql `premiered` database to the backups folder
echo successfully backed up mysql databasee
mysqldump --single-transaction -u root test | gzip  > $BACKUPFOLDER/$CONNECT

# finally, save the backups to s3 via s3fs
s3fs test-backups ./s3fs
cp $BACKUPFOLDER/$CONNECT ./s3fs/$CONNECT
echo succeessfully saved sql file to s3

When I run this as a shell command, $ ./backup.sh, it correctly saves the file to S3. However, when I run this command via cron, it literally saves the file to the local ./s3fs folder and does not save it to S3. Why does this occur and what do I need to do to fix this?

4

1 回答 1

2

cron 作业在cron默认情况下无权访问您的 S3 凭据的用户下执行。我想您将它们存储在您的S3_*环境变量中,但是 cron 作业在几乎空的环境中执行。

于 2012-05-14T21:34:43.637 回答