{ "info": { "author": "Pierre Mavro", "author_email": "deimos@deimos.fr", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Console", "License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Topic :: Communications" ], "description": "Simple EC2 Snapshot\n===================\n\nSimple solution to backup ec2 instances using snapshots\n\nWith Simple EC2 Snapshot supports:\n\n* Hot snapshots (by default) and Cold snapshots\n* Multiple instances snapshot in one line\n* Detection of doubles\n* Filters by tags (allowing wildcards) or by instance IDs\n* Credentials file multiple with profiles\n* Limit the number of snapshots\n* Restrict snapshots to data disks only\n* Snapshot retention over time or for a given number\n\n## Installation\n\nTo install the tool, the simplest solution is to use pip:\n```\npip install simplec2snap\n```\n\n## Filters\n\nYou can first decide to choose what to backup with Instance ID or Tags. You can set multiple tags and/or multiple instance ID at the same time.\n\nFor example, if I want to snapshot 2 instances in the same command line, it should looks like this:\n```\n> ./simplec2snap.py -i i-ad0fcc4b -i i-56489db2\n```\n\nTo snapshot multiple instances by selecting multiple tags. Here is an example with 2 tagsi, so it should match both:\n```\n> ./simplec2snap.py -t Name 'instance*' -t env prod\n```\n\nIf you want to add an instance in addition of the previous tags:\n```\n> ./simplec2snap.py -t Name 'instance*' -t env prod -i i-ad0fcc4b\n```\n\n## Credentials file\n\nYou can use a credentials file with several profiles. It should looks like this:\n```ini\n[default]\naws_region = \naws_access_key_id = \naws_secret_access_key = \n\n#[profile profile1]\n#aws_region = \n#aws_access_key_id = \n#aws_secret_access_key = \n```\nThe default one should be located in '~/.aws_cred'. You can override this with '-c' argument and '-p' to specify the profile fulfill into brackets.\n\n## Dry Run mode\n\nUse the dry run mode (enabled by default) to see what actions will be performed when selecting a tag Name or an instance:\n```\n> ./simplec2snap.py -t Name \"instance-name*\"\n2015-01-26 17:05:25,954 [INFO] == Launching dry run mode ==\n2015-01-26 17:05:25,954 [INFO] Connecting to AWS\n2015-01-26 17:05:25,955 [INFO] Getting instances information\n2015-01-26 17:05:28,341 [INFO] Working on instance i-e16cc205 (instance-name2)\n2015-01-26 17:05:28,341 [INFO] Hot snapshot made for vol-fa415bfd(/dev/sdb)\n2015-01-26 17:05:28,341 [INFO] Hot snapshot made for vol-22465c25(/dev/sda)\n2015-01-26 17:05:28,341 [INFO] Working on instance i-6f6ec08b (instance-name1)\n2015-01-26 17:05:28,341 [INFO] Hot snapshot made for vol-9d465c9a(/dev/sda)\n2015-01-26 17:05:28,341 [INFO] Hot snapshot made for vol-9c465c9b(/dev/sdb)\n```\n\n## Run mode\n\nIf you're ok with the previous dry run, then add '-u' for run mode:\n```\n> ./simplec2snap.py -t Name \"instance-name*\" -u\n2015-01-26 17:06:19,163 [INFO] == Launching run mode ==\n2015-01-26 17:06:19,163 [INFO] Connecting to AWS\n2015-01-26 17:06:19,163 [INFO] Getting instances information\n2015-01-26 17:06:21,083 [INFO] Working on instance i-e16cc205 (instance-name2)\n2015-01-26 17:06:21,352 [INFO] Hot snapshot made for vol-fa415bfd(/dev/sdb) - snap-35adb8c4\n2015-01-26 17:06:21,587 [INFO] Hot snapshot made for vol-22465c25(/dev/sda) - snap-36adb8c7\n2015-01-26 17:06:21,587 [INFO] Working on instance i-6f6ec08b (instance-name1)\n2015-01-26 17:06:21,832 [INFO] Hot snapshot made for vol-9d465c9a(/dev/sda) - snap-3cadb8cd\n2015-01-26 17:06:22,087 [INFO] Hot snapshot made for vol-9c465c9b(/dev/sdb) - snap-21adb8d0\n```\n\n## Hot vs Cold snapshot\n\nBy default Hot mode is selected to perform snapshot without stopping instances. However, this may not be the best choice in some case, like for database purpose. To get a full consistent snapshot of your EC2 with attached EBS, you have to make a Cold snapshot which involves to shutdown, snapshot and start instance.\n\nTo do so, you have to add '-H' option:\n```\n> ./simplec2snap.py -t Name \"instance-name*\" -u -H\n2015-01-26 17:07:10,281 [INFO] == Launching run mode ==\n2015-01-26 17:07:10,281 [INFO] Connecting to AWS\n2015-01-26 17:07:10,282 [INFO] Getting instances information\n2015-01-26 17:07:12,490 [INFO] Working on instance i-e16cc205 (instance-name2)\n2015-01-26 17:07:12,490 [INFO] Instance is going to be shutdown\n2015-01-26 17:07:48,871 [INFO] Instance i-e16cc205 now stopped !\n2015-01-26 17:07:49,134 [INFO] Cold snapshot made for vol-fa415bfd(/dev/sdb) - snap-a8afba59\n2015-01-26 17:07:49,379 [INFO] Cold snapshot made for vol-22465c25(/dev/sda) - snap-adafba5c\n2015-01-26 17:07:49,379 [INFO] Instance is going to be started\n2015-01-26 17:08:20,565 [INFO] Instance i-e16cc205 now running !\n2015-01-26 17:08:20,565 [INFO] Working on instance i-6f6ec08b (instance-name1)\n2015-01-26 17:08:20,565 [INFO] Instance is going to be shutdown\n2015-01-26 17:08:51,617 [INFO] Instance i-6f6ec08b now stopped !\n2015-01-26 17:08:51,853 [INFO] Cold snapshot made for vol-9d465c9a(/dev/sda) - snap-b1aebb40\n2015-01-26 17:08:52,098 [INFO] Cold snapshot made for vol-9c465c9b(/dev/sdb) - snap-b2aebb43\n2015-01-26 17:08:52,098 [INFO] Instance is going to be started\n2015-01-26 17:09:09,467 [INFO] Instance i-6f6ec08b now running !\n```\n\n## Limit snapshots for auto-scaling group\n\nIn auto-scaling groups, you normally have x time the same running intance. Snapshoting a huge number of time the same instance may not be very interesting. That's why you can limit the number of snapshot by using '-l' command followed by the number of desired snapshot. If I only want one:\n```\n> ./simplec2snap.py -t Name \"instance-name*\" -l 1 \n2015-01-26 17:11:27,561 [INFO] == Launching dry run mode ==\n2015-01-26 17:11:27,561 [INFO] Connecting to AWS\n2015-01-26 17:11:27,562 [INFO] Getting instances information\n2015-01-26 17:11:29,659 [INFO] Working on instance i-e16cc205 (instance-name2)\n2015-01-26 17:11:29,659 [INFO] Hot snapshot made for vol-fa415bfd(/dev/sdb)\n2015-01-26 17:11:29,659 [INFO] Hot snapshot made for vol-22465c25(/dev/sda)\n2015-01-26 17:11:29,659 [INFO] Working on instance i-6f6ec08b (instance-name1)\n2015-01-26 17:11:29,660 [INFO] The requested limit of snapshots has been reached: 1\n```\n\n## Remove root device from snapshots\n\nStill for auto-scaling groups, your root device may not be required to snapshot. Generally because it may be builded from a configuration manager and you just don't care of it. So the goal is to remove it from the snapshot list, you can so use '-o' option:\n\n```\n> ./simplec2snap.py -t Name \"instance-name*\" -o \n2015-01-26 17:11:50,757 [INFO] == Launching dry run mode ==\n2015-01-26 17:11:50,757 [INFO] Connecting to AWS\n2015-01-26 17:11:50,758 [INFO] Getting instances information\n2015-01-26 17:11:52,708 [INFO] Working on instance i-e16cc205 (instance-name2)\n2015-01-26 17:11:52,708 [INFO] Hot snapshot made for vol-fa415bfd(/dev/sdb)\n2015-01-26 17:11:52,708 [INFO] Working on instance i-6f6ec08b (instance-name1)\n2015-01-26 17:11:52,708 [INFO] Hot snapshot made for vol-9c465c9b(/dev/sdb)\n```\n\n## Snapshot retention\n\nThere are 2 methods for snapshot retention. Choose the best one for your needs.\n\n### Keep snapshots over time\n\nYou can define the retention of your backups. You need to specify 2 args:\n\n* Number: sepcify a number for day, week... which is defined in the second arg\n* Time element: specify s(second), m(min), h(hour), d(day), w(week), M(month), y(year)\n\nSo for example, if you want to keep snapshots for 3 weeks and delete the old ones, you have to set: 3 w.\n\nHere is a basic example where I want to delete snapshots older than 10 days:\n```\n> ./simplec2snap.py -t Name \"instance-name*\" -n -g 10 d\n2015-01-28 10:12:11,216 [INFO] == Launching dry run mode ==\n2015-01-28 10:12:11,217 [INFO] Connecting to AWS\n2015-01-28 10:12:11,217 [INFO] Getting instances information\n2015-01-28 10:12:13,080 [INFO] Working on instance i-e16cc205 (pmavro-test2)\n2015-01-28 10:12:14,109 [INFO] Deleting snapshot snap-b427c144 (vol-fa415bfd|/dev/sdb)\n2015-01-28 10:12:14,205 [INFO] Deleting snapshot snap-a327c153 (vol-22465c25|/dev/sda)\n2015-01-28 10:12:14,205 [INFO] Working on instance i-6f6ec08b (pmavro-test1)\n2015-01-28 10:12:14,321 [INFO] Deleting snapshot snap-a627c156 (vol-9d465c9a|/dev/sda)\n2015-01-28 10:12:14,440 [INFO] Deleting snapshot snap-a927c159 (vol-9c465c9b|/dev/sdb)\n```\n\nHere -n is used to not make snapshots, only delete olds. But you can ask on the same line to make snapshots AND remove old ones:\n```\n> ./simplec2snap.py -t Name \"instance-name*\" -g 10 m \n2015-01-26 17:22:43,263 [INFO] == Launching dry run mode ==\n2015-01-26 17:22:43,263 [INFO] Connecting to AWS\n2015-01-26 17:22:43,264 [INFO] Getting instances information\n2015-01-26 17:22:46,217 [INFO] Working on instance i-e16cc205 (instance-name2)\n2015-01-26 17:22:46,218 [INFO] Hot snapshot made for vol-fa415bfd(/dev/sdb)\n2015-01-26 17:22:46,218 [INFO] Hot snapshot made for vol-22465c25(/dev/sda)\n2015-01-26 17:22:47,328 [INFO] Deleting snapshot snap-a8afba59 (vol-fa415bfd|/dev/sdb)\n2015-01-26 17:22:47,491 [INFO] Deleting snapshot snap-adafba5c (vol-22465c25|/dev/sda)\n2015-01-26 17:22:47,491 [INFO] Working on instance i-6f6ec08b (instance-name1)\n2015-01-26 17:22:47,491 [INFO] Hot snapshot made for vol-9d465c9a(/dev/sda)\n2015-01-26 17:22:47,492 [INFO] Hot snapshot made for vol-9c465c9b(/dev/sdb)\n2015-01-26 17:22:47,669 [INFO] Deleting snapshot snap-b1aebb40 (vol-9d465c9a|/dev/sda)\n2015-01-26 17:22:47,842 [INFO] Deleting snapshot snap-b2aebb43 (vol-9c465c9b|/dev/sdb)\n```\n\n### Keep at least a given number of snapshots\n\nAnother solution to manage the retention of your snapshots is to specify how many snapshots you want to keep. For example, if I have 5 snapshots per device of an instance and want to keep the last 4 ones:\n```\n> ./simplec2snap.py -t Name \"instance-name*\" -n -d 4\n2015-01-28 10:14:02,713 [INFO] == Launching dry run mode ==\n2015-01-28 10:14:02,713 [INFO] Connecting to AWS\n2015-01-28 10:14:02,713 [INFO] Getting instances information\n2015-01-28 10:14:04,328 [INFO] Working on instance i-e16cc205 (pmavro-test2)\n2015-01-28 10:14:05,316 [INFO] Deleting snapshot snap-b427c144 (vol-fa415bfd|/dev/sdb)\n2015-01-28 10:14:05,444 [INFO] Deleting snapshot snap-a327c153 (vol-22465c25|/dev/sda)\n2015-01-28 10:14:05,444 [INFO] Working on instance i-6f6ec08b (pmavro-test1)\n2015-01-28 10:14:05,540 [INFO] Deleting snapshot snap-a627c156 (vol-9d465c9a|/dev/sda)\n2015-01-28 10:14:05,654 [INFO] Deleting snapshot snap-a927c159 (vol-9c465c9b|/dev/sdb)\n```\n\n## Help\n\nHere is the help with the complete list of options:\n```\n> ./simplec2snap.py \nusage: simplec2snap.py [-h] [-r REGION] [-k KEY_ID] [-a ACCESS_KEY]\n [-c CREDENTIALS] [-p CRED_PROFILE] [-i INSTANCE_ID]\n [-t ARG ARG] [-u] [-l LIMIT] [-H] [-m COLDSNAP_TIMEOUT]\n [-o] [-g ARG ARG] [-d KEEP_LAST_SNAPSHOTS] [-n]\n [-f FILE] [-s] [-v LEVEL] [-V]\n\nSimple EC2 Snapshot utility\n\noptional arguments:\n -h, --help show this help message and exit\n -r REGION, --region REGION\n Set AWS region (ex: eu-west-1) (default: None)\n -k KEY_ID, --key_id KEY_ID\n Set AWS Key ID (default: None)\n -a ACCESS_KEY, --access_key ACCESS_KEY\n Set AWS Access Key (default: None)\n -c CREDENTIALS, --credentials CREDENTIALS\n Credentials file path (default:\n /home/pmavro/.aws_cred)\n -p CRED_PROFILE, --profile CRED_PROFILE\n Credentials profile file defined in credentials file\n (default: default)\n -i INSTANCE_ID, --instance INSTANCE_ID\n Instance ID (ex: i-00000000 or all) (default: [])\n -t ARG ARG, --tags ARG ARG\n Select tags with values (ex: tagname value) (default:\n [])\n -u, --dry_run Define if it should make snapshot or just dry run\n (default: True)\n -l LIMIT, --limit LIMIT\n Limit the number of snapshot (can be usefull with\n auto-scaling groups) (default: -1)\n -H, --cold_snap Make cold snapshot for a better consistency\n (Recommended) (default: False)\n -m COLDSNAP_TIMEOUT, --timeout COLDSNAP_TIMEOUT\n Instance timeout (in seconds) for stop and start\n during a cold snapshot (default: 600)\n -o, --no_root_device Do not snapshot root device (default: False)\n -g ARG ARG, --max_age ARG ARG\n Maximum snapshot age to keep ( )\n (ex: 1 h for one hour) (default: [])\n -d KEEP_LAST_SNAPSHOTS, --keep_last_snapshots KEEP_LAST_SNAPSHOTS\n Keep the x last snapshots (default: 0)\n -n, --no_snap Do not make snapshot (useful when combien to -g\n option) (default: False)\n -f FILE, --file_output FILE\n Set an output file (default: None)\n -s, --stdout Log output to console (stdout) (default: True)\n -v LEVEL, --verbosity LEVEL\n Verbosity level: DEBUG/INFO/ERROR/CRITICAL (default:\n INFO)\n -V, --version Print version number\n```", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/enovance/simple_ec2_snapshot", "keywords": null, "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "simplec2snap", "package_url": "https://pypi.org/project/simplec2snap/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/simplec2snap/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/enovance/simple_ec2_snapshot" }, "release_url": "https://pypi.org/project/simplec2snap/v0.5/", "requires_dist": null, "requires_python": null, "summary": "Simple solution to backup ec2 instances using snapshots", "version": "v0.5" }, "last_serial": 1710618, "releases": { "v0.4": [ { "comment_text": "", "digests": { "md5": "99f46f04ed11a9aa2fdffd7aff59c3b8", "sha256": "bdc898ec4c7ceb73979eed062ae8798ab6db80cfa9e02c82434473874b2a4dec" }, "downloads": -1, "filename": "simplec2snap-v0.4.tar.gz", "has_sig": false, "md5_digest": "99f46f04ed11a9aa2fdffd7aff59c3b8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4899, "upload_time": "2015-01-28T16:29:32", "url": "https://files.pythonhosted.org/packages/30/61/a5034a95a6f9a018a614cec441699014628dcec7f1b9f4d8e9ea65cd21ec/simplec2snap-v0.4.tar.gz" } ], "v0.5": [] }, "urls": [] }