Skip to content

Add GCS bucket version audit and restore scripts #30

@anth-volk

Description

@anth-volk

Summary

Add two Python scripts for auditing and restoring GCS bucket objects to a previous point-in-time using object versioning.

Scripts

gcs_version_audit.py (read-only)

  • Lists all object versions in a GCS bucket
  • Classifies each object: already correct, needs restore, or created after target date
  • Reports total restore size and estimated Coldline retrieval cost
  • Supports --limit for testing, --show-all-versions for verbose output, and --prefix for scoping

gcs_restore.py (write, with safeguards)

  • Restores all objects to their state at a given target datetime
  • Dry-run by default — requires --execute flag to make changes
  • Even with --execute, prompts for interactive yes confirmation
  • Parallel execution with configurable worker count
  • Optional --delete-new flag to remove objects created after the target date

Use case

When a GCS bucket with object versioning enabled needs to be rolled back to a known-good state (e.g., after accidental bulk deletions or overwrites), these scripts provide a safe audit-then-restore workflow.

Requirements

  • google-cloud-storage Python package
  • GCP credentials with read access (audit) or read+write access (restore)
  • Object versioning must be enabled on the target bucket

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions