-
-
Save eduardocereto/259646 to your computer and use it in GitHub Desktop.
bundle s3 AMI to EBS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
mkdir /mnt/ebs | |
mkfs.ext3 ${EBS_DEVICE} | |
mount ${EBS_DEVICE} /mnt/ebs | |
mkdir /mnt/tmp | |
rsync -av --exclude=/mnt/ --exclude=/proc/ / /mnt/tmp/ | |
rm /mnt/tmp/root/.bash_history | |
rm /mnt/tmp/home/*/.bash_history | |
rm /mnt/tmp/etc/ssh/ssh_host_* | |
rm /mnt/tmp/etc/ssh/moduli | |
rm /mnt/tmp/etc/udev/rules.d/*persistent-net.rules | |
#ensure that ami init scripts will be run | |
chmod u+x /mnt/ebs/etc/init.d/ec2-init-user-data | |
rm /mnt/ebs/var/lib/ec2 | |
#clear out log files | |
cd /mnt/tmp/var/log | |
for i in `ls ./**/*`; do | |
echo $i && echo -n> $i | |
done | |
# rsync --stats -avx --exclude-from=excludes.txt / /mnt/ebs/ | |
cd /mnt/tmp | |
# tar cpS ./ | cpipe -vt -b 1024 | gzip -c | tar zxpS -C /mnt/ebs/ | |
tar -cSf - -C ./ . | tar xvf - -C /mnt/ebs/ | |
mv /mnt/ebs/mnt/tmp/* /mnt/ebs/ #FIX THIS UGLYNESS | |
umount /mnt/ebs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo '' | |
echo " | |
sudo -s | |
mkdir /mnt/ebs | |
mkfs.ext3 ${EBS_DEVICE} | |
mount ${EBS_DEVICE} /mnt/ebs | |
mkdir /mnt/tmp | |
rsync -av --exclude=/mnt/ --exclude=/proc/ / /mnt/tmp/ | |
rm /mnt/tmp/root/.bash_history | |
rm /mnt/tmp/home/*/.bash_history | |
rm /mnt/tmp/etc/ssh/ssh_host_* | |
rm /mnt/tmp/etc/ssh/moduli | |
rm /mnt/tmp/etc/udev/rules.d/*persistent-net.rules | |
#ensure that ami init scripts will be run | |
chmod u+x /mnt/ebs/etc/init.d/ec2-init-user-data | |
rm /mnt/ebs/var/lib/ec2 | |
#clear out log files | |
cd /mnt/tmp/var/log | |
for i in `ls ./**/*`; do | |
echo $i && echo -n> $i | |
done | |
# rsync --stats -avx --exclude-from=excludes.txt / /mnt/ebs/ | |
cd /mnt/tmp | |
# tar cpS ./ | cpipe -vt -b 1024 | gzip -c | tar zxpS -C /mnt/ebs/ | |
tar -cSf - -C ./ . | tar xvf - -C /mnt/ebs/ | |
mv /mnt/ebs/mnt/tmp/* /mnt/ebs/ #FIX THIS UGLYNESS | |
umount /mnt/ebs | |
" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment