backup module

Fabric tasks

django_fabfile.backup.backup_instance()[source]

Return list of created snapshots for specified instance.

region_name
instance location;
instance, instance_id
either instance_id or instance argument should be specified;
synchronously
wait for successful completion. False by default.
consistent
if True, then FS mountpoint will be frozen before snapshotting. False by default.
django_fabfile.backup.backup_instances_by_tag()[source]

Creates backup for all instances with given tag in region.

region_name
will be applied across all regions by default;
tag_name, tag_value
will be fetched from config by default;
synchronously
will be accomplished with assuring successful result. False by default;
consistent
if True, then FS mountpoint will be frozen before snapshotting.

Note

when create_ami task compiles AMI from several snapshots it restricts snapshot start_time difference with 10 minutes interval at most. Snapshot completion may take much more time and due to this only asynchronously generated snapshots will be assembled assurely.

django_fabfile.backup.delete_broken_snapshots()[source]

Delete snapshots with status ‘error’.

django_fabfile.backup.rsync_all_regions()[source]

Replicates snapshots across all regions.

Sync snapshots from all but primary regions into primary. And then snapshots from primary regions will be replicated into secondary backup region.

Parameters:
  • primary_backup_region (str) – AWS region name that keeps all snapshots clones;
  • secondary_backup_region (str) – AWS region name that keeps clones of snapshots from primary_backup_region.
django_fabfile.backup.rsync_mountpoints()[source]

Run rsync against mountpoints, copy disk label.

Parameters:
  • src_inst – source instance;
  • src_vol – source volume with label that will be copied to dst_vol;
  • src_mnt – root or directory hierarchy to replicate;
  • dst_inst – destination instance;
  • dst_vol – destination volume, that will be marked with label from src_vol;
  • dst_mnt – destination point where source hierarchy to place;
  • encr (bool.) – True if volume is encrypted;
django_fabfile.backup.rsync_region()[source]

Duplicates latest snapshots with given tag into dst_region.

src_region_name, dst_region_name
every latest volume snapshot from src_region will be rsynced to the dst_region;
tag_name, tag_value
snapshots will be filtered by tag. Tag will be fetched from config by default;
native_only
sync only snapshots, created in the src_region_name. True by default.
django_fabfile.backup.rsync_snapshot()[source]

Duplicate the snapshot into dst_region.

src_region_name, dst_region_name
Amazon region names. Allowed to be contracted, e.g. ap-southeast-1 will be recognized in ap-south or even ap-s;
snapshot_id
snapshot to duplicate;
src_inst, dst_inst
will be used instead of creating new for temporary;
force
rsync snapshot even if newer version exist.

You’ll need to open port 60000 for encrypted instances replication.

django_fabfile.backup.trim_snapshots()[source]

Delete old snapshots logarithmically back in time.

region_name
by default process all regions;
dry_run
boolean, only print info about old snapshots to be deleted.

Internals

Check Fabric tasks for Django and Amazon Web Services or django_fabfile.utils.Config docstring for setup instructions.

django_fabfile.backup.backup_instance[source]

Return list of created snapshots for specified instance.

region_name
instance location;
instance, instance_id
either instance_id or instance argument should be specified;
synchronously
wait for successful completion. False by default.
consistent
if True, then FS mountpoint will be frozen before snapshotting. False by default.
django_fabfile.backup.backup_instances_by_tag[source]

Creates backup for all instances with given tag in region.

region_name
will be applied across all regions by default;
tag_name, tag_value
will be fetched from config by default;
synchronously
will be accomplished with assuring successful result. False by default;
consistent
if True, then FS mountpoint will be frozen before snapshotting.

Note

when create_ami task compiles AMI from several snapshots it restricts snapshot start_time difference with 10 minutes interval at most. Snapshot completion may take much more time and due to this only asynchronously generated snapshots will be assembled assurely.

django_fabfile.backup.create_snapshot(vol, description='', tags=None, synchronously=True, consistent=False)[source]

Return new snapshot for the volume.

vol
volume to snapshot;
synchronously
wait for successful completion;
description
description for snapshot. Will be compiled from instnace parameters by default;
tags
tags to be added to snapshot. Will be cloned from volume and from instance by default.
consistent
if consistent True, script will try to freeze fs mountpoint and create snapshot while it’s freezed with all buffers dumped to disk.
django_fabfile.backup.create_tmp_volume(*args, **kwds)[source]

Format new filesystem.

django_fabfile.backup.delete_broken_snapshots[source]

Delete snapshots with status ‘error’.

django_fabfile.backup.get_oldest_replica(src_conn, dst_conn, amount=1, native_only=True, tag_name='Earmarking', tag_value='production')[source]

Return list with (one by default) not yet replicated snapshots.

django_fabfile.backup.get_relevant_snapshots(conn, tag_name='Earmarking', tag_value='production', native_only=True, filters={'status': ['pending', 'completed']})[source]

Returns snapshots with proper description.

django_fabfile.backup.rsync_all_regions[source]

Replicates snapshots across all regions.

Sync snapshots from all but primary regions into primary. And then snapshots from primary regions will be replicated into secondary backup region.

Parameters:
  • primary_backup_region (str) – AWS region name that keeps all snapshots clones;
  • secondary_backup_region (str) – AWS region name that keeps clones of snapshots from primary_backup_region.
django_fabfile.backup.rsync_mountpoints[source]

Run rsync against mountpoints, copy disk label.

Parameters:
  • src_inst – source instance;
  • src_vol – source volume with label that will be copied to dst_vol;
  • src_mnt – root or directory hierarchy to replicate;
  • dst_inst – destination instance;
  • dst_vol – destination volume, that will be marked with label from src_vol;
  • dst_mnt – destination point where source hierarchy to place;
  • encr (bool.) – True if volume is encrypted;
django_fabfile.backup.rsync_region[source]

Duplicates latest snapshots with given tag into dst_region.

src_region_name, dst_region_name
every latest volume snapshot from src_region will be rsynced to the dst_region;
tag_name, tag_value
snapshots will be filtered by tag. Tag will be fetched from config by default;
native_only
sync only snapshots, created in the src_region_name. True by default.
django_fabfile.backup.rsync_snapshot[source]

Duplicate the snapshot into dst_region.

src_region_name, dst_region_name
Amazon region names. Allowed to be contracted, e.g. ap-southeast-1 will be recognized in ap-south or even ap-s;
snapshot_id
snapshot to duplicate;
src_inst, dst_inst
will be used instead of creating new for temporary;
force
rsync snapshot even if newer version exist.

You’ll need to open port 60000 for encrypted instances replication.

django_fabfile.backup.trim_snapshots[source]

Delete old snapshots logarithmically back in time.

region_name
by default process all regions;
dry_run
boolean, only print info about old snapshots to be deleted.
django_fabfile.backup.update_snap(src_vol, src_mnt, dst_vol, dst_mnt, encr, delete_old=False)[source]

Update destination region from src_vol.

Create new snapshot with same description and tags. Delete previous snapshot (if exists) of the same volume in destination region if delete_old is True.

Table Of Contents

Previous topic

Fabric tasks for Django and Amazon Web Services

Next topic

instances module

This Page