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.
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? – David Levesque – 2014-06-27T21:44:41.107
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. – Daryl Bennett – 2014-06-30T20:12:30.227@DavidLevesque, it might also be worth noting that before the
chown
the permissions were as such:-rwxr-xr-x 1 root root
– Daryl Bennett – 2014-06-30T21:40:27.877