Amazon EC2 EBS automatic backup one-liner works manually but not from cron
- by dan
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.