0

I have a new ec2 Ubuntu instance running. I have properly set up the ec2-api tools. I want to create a daily backup using the ec2-create-snapshot command. Just to test it, I have my script, which is named dailyBackup, and located in the /etc/cron.daily directory. I have the chmod +x permissions set.
Its recognized when I do:

run-parts --test /etc/cron.daily

When I run the following script as such:

. dailybackUp

Code within dailyBackup

#!/bin/bash
#This creates a backup of the root and xvdf volumes associated with this instance.
echo "Modifying the timezone to us-west-2..."
export EC2_URL=https://ec2.us-west-2.amazonaws.com
echo "Creating daily backup for root volume"
ec2-create-snapshot vol-id --description "SkySpark Linux Daily Backup Root"
echo "Creating daily backup for storage  volume"
ec2-create-snapshot vol-id--description " SkySpark Linux Daily Backup Storage "

I've omitted the volume ids, but, they're correct in my file.

It works just fine. This is the behavior I want. It backs up the volumes and I am able to view them in the console. I want this to occur daily. But, I have to manually call my script. It doesn't automatically get executed daily as I'd expect. Am I missing a step? Are my files configured incorrectly? Is the ec2-create-snapshot command unable to be executed in a job? Do I need to do something with cron?

Question also asked here.

3
  • Is your cron script owned by root and not writable by group or other? Also when you run the script manually, do you run is as root? Jun 27, 2014 at 21:44
  • It was owned by root. I ran the following: sudo chown ubuntu:root dailyBackup It now reads -rwxr-xr-x 1 ubuntu root 461 Jun 30 14:08 dailyBackup I am running the script manually as ubuntu. Jun 30, 2014 at 20:12
  • @DavidLevesque, it might also be worth noting that before the chown the permissions were as such: -rwxr-xr-x 1 root root Jun 30, 2014 at 21:40

1 Answer 1

0

I got the answer. I set up the postfix email service, and at once I was able to see the problem. It had nothing to do with root owning the file

You need to export the passwords in order to use the ec2 tools. I put the following at the top of my script, and now it works perfectly.

 export AWS_ACCESS_KEY="xxxxxxxxxxx"
 export AWS_SECRET_KEY="xxxxxxxxxxxxx"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .