Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Run this script on the instance to be bundled
- EBS_DEVICE=${1:-'/dev/sdh'}
- mkdir /mnt/ebs
- mkfs.ext3 ${EBS_DEVICE}
- mount ${EBS_DEVICE} /mnt/ebs
- #make a local working copy
- mkdir /mnt/tmp
- rsync -av --exclude=/mnt/ --exclude=/proc/* / /mnt/tmp/
- #remove files that should be instance specific
- 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
- cd /mnt/tmp
- tar -cSf - -C ./ . | tar xvf - -C /mnt/ebs/
- #NOTE, rsync could be used, but this tar trickery saves some space in the snapshot
- umount /mnt/ebs
Add Comment
Please, Sign In to add comment