Posts Tagged ‘Backups’
ec2-consistent-snapshot fails during cron
I was getting the following errors when running ec2-consistent-snapshot to create automatic nightly backups of an EBS volume. You can find Eric Hammond’s ec2-consistent-snapshot script here.
Backing up volume vol-06ca566f Can't exec "xfs_freeze": No such file or directory at /usr/bin/ec2-consistent-snapshot line 470. ec2-consistent-snapshot: ERROR: xfs_freeze -f /vol: failed(-1) snap-3a387653 Can't exec "xfs_freeze": No such file or directory at /usr/bin/ec2-consistent-snapshot line 470. ec2-consistent-snapshot: ERROR: xfs_freeze -u /vol: failed(-1) PHP Notice: Undefined index: v in /opt/scripts/backup/remove_old_snapshots.php on line 28 PHP Notice: Undefined index: v in /opt/scripts/backup/remove_old_snapshots.php on line 31 PHP Notice: Undefined index: n in /opt/scripts/backup/remove_old_snapshots.php on line 34 ERROR: Please provide number of snapshots to keep (-n option) Completed
This batch job ran fine manually, but fails when executed via cron. The problem is that cron has a different path than a shell environment.
You can fix the issue by adding the following line to the beginning of the cron. This adds the path to the cron so that it can execute files in various directories.
$ sudo crontab -e
add this line
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin