Skip to main content

Utility for downloading EBS snapshots using the EBS Direct API's

Project description

Python package

DSnap

Utility for downloading EBS snapshots using the EBS Direct API's.

Install

PyPi

NOTE: This won't work until this package is published, for now see Development

% pip install 'dsnap[cli]'

Examples

Listing Snapshots

% dsnap --profile demo list
           Id          |   Owner ID   |   State
snap-0dbb0347f47e38b96   922105094392   completed

Downloading a Snapshot

% dsnap --profile demo get snap-0dbb0347f47e38b96
Output Path: /cwd/snap-0dbb0347f47e38b96.img

If you don't specify a snapshot you'll get a prompt to ask which one you want to download:

% python -m dsnap --profile chris get
0) i-01f0841393cd39f06 (ip-172-31-27-0.ec2.internal, vpc-04a91864355539a41, subnet-0e56cd55282fa9158)
Select Instance: 0
0) vol-0a1aab48b0bc3039d (/dev/sdb)
1) vol-0c616d718ab00e70c (/dev/xvda)
Select Volume: 0
No snapshots found, create one? [y/N]: y
Creating snapshot for Instance(s): i-01f0841393cd39f06 /dev/sdb, Volume: vol-0a1aab48b0bc3039d
Waiting for snapshot to complete.
Output Path: /cwd/snap-0dbb0347f47e38b96.img
Cleaning up snapshot: snap-0543a8681adce0086

Mounting in Vagrant

This requires virtualbox to be installed. dsnap init will write a Vagrantfile to the current directory that can be used to mount a specific downloaded snapshot. Conversion to a VDI disk is handled in the Vagrantfile, it will look for the disk file specified in the IMAGE environment variable, convert it to a VDI using VBoxManage convertdd. The resulting VDI is destroyed when the Vagrant box is, however the original raw .img file will remain and can be reused as needed.

% dsnap init
% IMAGE=snap-0543a8681adce0086.img vagrant up
% vagrant ssh

Mounting With Docker

This uses libguestfs to work directly with the downloaded img file.

Build Docker Container

git clone https://github.com/RhinoSecurityLabs/dsnap.git
cd dsnap
make docker/build

Run Guestfish Shell

IMAGE=snap-0dbb0347f47e38b96.img make docker/run

This will take a second to start up. After it drops you into the shell you should be able to run commands like ls, cd, cat. However worth noting they don't always behave exactly like they do in a normal shell.

The output will give you the basics of how to use the guestfish shell. For a full list of command you can run help --list.

Below is an example of starting the shell and printing the contents of /etc/os-release.

% IMAGE=snap-0dbb0347f47e38b96.img make docker/run
docker run -it -v "/cwd/dsnap/snap-0dbb0347f47e38b96.img:/disks/snap-0dbb0347f47e38b96.img" -w /disks mount --ro -a "snap-0dbb0347f47e38b96.img" -m /dev/sda1:/

Welcome to guestfish, the guest filesystem shell for
editing virtual machine filesystems and disk images.

Type: ‘help’ for help on commands
      ‘man’ to read the manual
      ‘quit’ to quit the shell

><fs> cat /etc/os-release
NAME="Amazon Linux"
VERSION="2"
ID="amzn"
ID_LIKE="centos rhel fedora"
VERSION_ID="2"
PRETTY_NAME="Amazon Linux 2"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2"
HOME_URL="https://amazonlinux.com/"

Development

For CLI development make sure you include the cli extra shown below. You'll also want to invoke the package by using python's -m (shown below) for testing local changes, the dnsap binary installed to the environment will only update when you run pip install.

Setup

git clone https://github.com/RhinoSecurityLabs/dsnap.git
cd dsnap
python3 -m venv venv
. venv/bin/activate
python -m pip install '.[cli]'

Running With Local Changes

python -m dsnap --help

Linting and Type Checking

make lint

Testing

make test

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dsnap-0.1.5.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dsnap-0.1.5-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file dsnap-0.1.5.tar.gz.

File metadata

  • Download URL: dsnap-0.1.5.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.9.1 Linux/5.4.0-1039-azure

File hashes

Hashes for dsnap-0.1.5.tar.gz
Algorithm Hash digest
SHA256 13935b3d22b6b6371745a0a8e92a164ae78c2d063b5992504dfd6c3ff78b7e69
MD5 fadbe6bd31159526ec845a853e3e2000
BLAKE2b-256 400e1a8ba19615b8093a269a9a1d9e5509128788ba91a656f14f03e9c3a1395c

See more details on using hashes here.

File details

Details for the file dsnap-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: dsnap-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 10.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.9.1 Linux/5.4.0-1039-azure

File hashes

Hashes for dsnap-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 f34a21292b69671d1a3535d755d1d4ff329350d9a505be50021d8667879ac1cc
MD5 70e7c8bf883bc1252bfca875a15bf622
BLAKE2b-256 2e9f16538d600b5d952cbba265c47535591e2aac13a5fc3b6fed9d3761e28849

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page