Hello
Bellow is a script for backup up a redis on a unmounted ebs volume . First of all you have to create this file on that ebs
/mnt/backup/mounted
Why  I use this  ? Well I use it because I want to run on multiple servers.
#!/bin/bash
instance=i-xxxxx
volume=vol-xxxx
iplocalhost=10.00.00.111
mkdir /mnt/backup
atached=0
if [ ! -f /tmp/redis1 ]; then
touch /tmp/redis1
else
exit 0
fi
export EC2_HOME=/path/ec2-1.4.4.2
export JAVA_HOME=/usr/lib/jvm/jre
export CLASSPATH=${EC2_HOME}/lib
export EC2_PRIVATE_KEY=/root/path/pk.pem
export EC2_CERT=/root/path/cert.pem
while [ $atached -lt 1 ];do
/path/ec2-1.4.4.2/bin/ec2-attach-volume -K /root/path/pk.pem -C /root/path/cert.pem $volume -i $instance -d /dev/sdh
sleep 10
mount /dev/sdh /mnt/backup
sleep 5
if [ -f /mnt/backup/mounted ]; then
rsync -vrplogDtH /var/lib/redis/6379 /mnt/backup/cassandra1
atached=1
fi
done
cd /
umount -lf /mnt/backup
sleep 3
/path/ec2-1.4.4.2/bin/ec2-detach-volume -K /root/path/pk.pem -C /root/path/cert.pem $volume -i $instance -d /dev/sdh
rm -rf /tmp/redis1
[…] with the script bellow automatic script for backup up redis on a amazon ebs I saw that was a problem. From time to time the ebs hang with “attaching” And the mount […]
Pingback by EBS hangs in “attaching” mode | How to , and other stuff about linux, photo, php ... — February 9, 2012 @ 11:32 am