Amazon EC2 EBS automatic backup one-liner works manually but not from cron

Posted by dan on Stack Overflow See other posts from Stack Overflow or by dan
Published on 2012-12-13T12:58:04Z Indexed on 2012/12/18 23:03 UTC
Read the original article Hit count: 426

I am trying to implement an automatic backup system for my EBS on Amazon AWS.

When I run this command as ec2-user:

/opt/aws/bin/ec2-create-snapshot --region us-east-1 -K /home/ec2-user/pk.pem -C /home/ec2-user/cert.pem -d "vol-******** snapshot" vol-********

everything works fine.

But if I add this line into /etc/crontab and restart the crond service:

15 12 * * * ec2-user /opt/aws/bin/ec2-create-snapshot --region us-east-1 -K /home/ec2-user/pk.pem -C /home/ec2-user/cert.pem -d "vol-******** snapshot" vol-********

that doesn't work.

I checked var/log/cron and there is this line, therefore the command gets executed:

Dec 13 12:15:01 ip-10-204-111-94 CROND[4201]: (ec2-user) CMD (/opt/aws/bin/ec2-create-snapshot --region us-east-1 -K /home/ec2-user/pk.pem -C /home/ec2-user/cert.pem -d "vol-******** snapshot" vol-******** )

Can you please help me to troubleshoot the problem?

I guess is some environment problem - maybe the lack of some variable. If that's the case I don't know what to do about it.

Thanks.

© Stack Overflow or respective owner

Related posts about amazon-web-services

Related posts about amazon-ec2