Submit
Path:
~
/
/
proc
/
thread-self
/
root
/
usr
/
lib
/
python2.7
/
site-packages
/
boto
/
pyami
/
installers
/
ubuntu
/
File Content:
ebs.pyc
� �vWc @ s� d Z d d l Z d d l m Z d d l m Z d d l Z d d l Z d d l m Z d d l m Z d Z d Z d Z d e f d � � YZ d S( s Automated installer to attach, format and mount an EBS volume. This installer assumes that you want the volume formatted as an XFS file system. To drive this installer, you need the following section in the boto config passed to the new instance. You also need to install dateutil by listing python-dateutil in the list of packages to be installed in the Pyami seciont of your boto config file. If there is already a device mounted at the specified mount point, the installer assumes that it is the ephemeral drive and unmounts it, remounts it as /tmp and chmods it to 777. Config file section:: [EBS] volume_id = <the id of the EBS volume, should look like vol-xxxxxxxx> logical_volume_name = <the name of the logical volume that contaings a reference to the physical volume to be mounted. If this parameter is supplied, it overrides the volume_id setting.> device = <the linux device the EBS volume should be mounted on> mount_point = <directory to mount device, defaults to /ebs> i����N( t Volume( t EC2ResponseError( t Installer( t Templatesc #!/usr/bin/env python # Backup EBS volume import boto from boto.pyami.scriptbase import ScriptBase import traceback class Backup(ScriptBase): def main(self): try: ec2 = boto.connect_ec2() self.run("/usr/sbin/xfs_freeze -f ${mount_point}", exit_on_error = True) snapshot = ec2.create_snapshot('${volume_id}') boto.log.info("Snapshot created: %s " % snapshot) except Exception as e: self.notify(subject="${instance_id} Backup Failed", body=traceback.format_exc()) boto.log.info("Snapshot created: ${volume_id}") except Exception as e: self.notify(subject="${instance_id} Backup Failed", body=traceback.format_exc()) finally: self.run("/usr/sbin/xfs_freeze -u ${mount_point}") if __name__ == "__main__": b = Backup() b.main() s� #!/usr/bin/env python import boto from boto.manage.volume import Volume # Cleans Backups of EBS volumes for v in Volume.all(): v.trim_snapshots(True) sr #!/usr/bin/env python import boto # Cleans Backups of EBS volumes ec2 = boto.connect_ec2() ec2.trim_snapshots() t EBSInstallerc B se e Z d Z d d � Z d � Z d � Z d � Z e d � Z d � Z d � Z d � Z d � Z RS( s Set up the EBS stuff c C s� t t | � j | � t j j d d � | _ t j j d d d � | _ t j j d d � | _ t j j d d � | _ t j j d d d � | _ d S( Nt Instances instance-idt EBSt devices /dev/sdpt volume_idt logical_volume_namet mount_points /ebs( t superR t __init__t botot configt gett instance_idR R R R ( t selft config_file( ( sD /usr/lib/python2.7/site-packages/boto/pyami/installers/ubuntu/ebs.pyR h s c C s� t j � } | j r? t t j d | j � � } | j | _ n | j | j g � d } xC | j � d k r� t j j d | j | j f � t j d � q[ W| j | j g � d } t } x� | rPy&