Skip to content

Instantly share code, notes, and snippets.

View crazycodr's full-sized avatar

Mathieu Dumoulin crazycodr

View GitHub Profile
@crazycodr
crazycodr / aws-s3-mass-undelete.sh
Last active September 16, 2022 16:56
Batch restore deleted s3 objects by accident
# Set the bucket name and date limit that you want to scan for...
#
# For example, if you deleted everything at 9'ish, set the DATE_LIMIT for a
# few minutes before to ensure you find only the stuff you deleted by error
#
BUCKET_NAME="..."
DATE_LIMIT="0000-00-00T00:00:00.000Z"
aws s3api list-object-versions --bucket "${BUCKET_NAME}" > objects.json
cat objects.json | jq --arg DATE_LIMIT "${DATE_LIMIT}" '[ .DeleteMarkers[] | select(.LastModified > $DATE_LIMIT and .IsLatest) | { file: .Key, version: .VersionId } ]' > markers-to-delete.json
@crazycodr
crazycodr / sync-out.sh
Created January 18, 2018 03:51
EFS docker image cache
#!/bin/bash
set -euo pipefail
docker_image_manifest_directory="$(mktemp -d "docker-image-manifest.XXXX")"
docker inspect $(docker images -q) \
| jq '[.[] | { id: .Id, tags: .RepoTags[] | split(":") } | { id: .id, repository: .tags[0], version: .tags[1] } ] | unique' \
> "${docker_image_manifest_directory}/image.manifest"
@crazycodr
crazycodr / onename blockchain id verification
Created January 8, 2016 18:35
onename blockchain id verification
Verifying that +crazycodr is my blockchain ID. https://onename.com/crazycodr