Creates and Rotates EBS snapshots
snap.sh [options] ... command
Commands: snapshot Takes a snapshot of volumes matching the given filters cleanup Cleans up old snapshots maintain Performs snapshots, then runs cleanup
[all] --help Shows the help message --volume An explicit list of volumes to operate on --instance List of instances to check for volumes --tag-list List of tags to check volumes for snapshotting --dry-run Don't actually do anything! --debug Show debug output
[snapshot] Takes a snapshot of a list of volumes. The list of volumes can be given via --volume, or found by searching AWS volumes. --tag-map List of tags to clone from volume to snapshot
[cleanup] Cleans the snapshot list, removing snapshots older than the given age or date (default: 7 days) --snapshot-tag-filter List of tags to filter on volumes during snapshot cleanup --max-age Maxiumum age of snapshots to keep --max-date Maximum date of snapshot to keep --no-max-date Do not filter by dates at all (equal to --max-date=0)
Tags are matched in a case-sensitive manner. Tags can be matched by key existence (--tag-list key_name
) or by key-value (--tag-list key_name=value
). Multiple tags are supported, but multiple values for the same tag are currently not.
The volume discovery algorithm works like this:
- If nothing is passed on the command line, discover all instances and all volumes attached to those instances.
- If a list of instances is passed, add all volumes for those instances to the discovery list.
- If a list of volumes is passed, add the given volumes to the discovery list.
Finally, if tags are given via --tag-list
, remove any item that does not match at least one of the tag keys or key-values given.
If a tag map is given, the value of the tag is copied from the volume to the newly-created snapshot. A new name for the tag may be given as a key-value pair.
A config file can be given via an AWS_CONFIG
environment variable. This provides the ability to import the AWS_ACCESS_KEY_ID
and AWS_SECRET_ACCESS_KEY
, as well as set some of the script defaults.
Filtering functions return 0 if the filter is successful, and 1 otherwise