You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Migration Runbook: Legacy MS Access/SQL Server → GCP Cloud SQL for Postgres/PostGIS**Owner:** Data Platform Team
**Runbook Version:** 1.0
**Last Updated:** 2025-08-26
**Related ADR:** Migration from Legacy MS Access/SQL Server to GCP Postgres/PostGIS
---## 0) Overview
This runbook describes the end‑to‑end, repeatable migration of data from legacy Microsoft Access and SQL Server databases to Google Cloud SQL for Postgres with PostGIS enabled. It includes prep, environment setup, schema deployment, data extraction, transformation, load, validation, performance tuning, cutover, and rollback.
> **Assumptions**> - Target is **Cloud SQL for Postgres** v14+ with **PostGIS** extension.> - ETL implemented in **Python** using **SQLAlchemy** (Core or ORM), optional **pandas** for staging.> - Access to legacy data sources (Access .mdb/.accdb files, SQL Server instance) via network or file share.---## 1) Roles & Contacts-**Run Lead:**`<name>` (approver for go/no‑go)
-**DBA / Cloud SQL Admin:**`<name>`-**Data Engineer (ETL):**`<name>`-**Geospatial SME:**`<name>`-**Stakeholders:**`<names>`---## 2) Change Ticket & Schedule-**Change ticket:**`<ID>`-**Window:**`<date/time in local + UTC>`-**Freeze period:** No schema changes on sources 24h before cutover.
-**Back‑out window:**`<duration>`---## 3) Prerequisites & Tooling-**Local/CI**: Python 3.11+, `virtualenv` or `uv`, `psql`, `pg_dump`, `pg_restore`.
-**Python libs**: `sqlalchemy`, `psycopg[binary]` or `psycopg2-binary`, `pyodbc`, `pandas` (optional), `shapely`, `geoalchemy2`, `python-dotenv`, `pyproj`.
-**Access connectors**: `mdbtools` (for .mdb) or Access ODBC driver (Windows), or `pyodbc` with ACE OLEDB (Windows).
-**SQL Server**: ODBC driver 18+, or `bcp`/`sqlcmd` (optional).
-**GCP**: `gcloud` CLI, IAM permissions to Cloud SQL Admin/Client, Secret Manager access.
---## 4) Environment & Secrets
Create a `.env` (or Secret Manager entries) for both source and target connections.
```ini# Target Postgres (Cloud SQL)PGHOST=<cloud-sql-proxy-host-or-ip>
PGPORT=5432
PGDATABASE=<target_db>
PGUSER=<app_user>
PGPASSWORD=<password or use IAM/db role>
PGSSLMODE=require
# SQL Server sourceMSSQL_DSN="Driver={ODBC Driver 18 for SQL Server};Server=<host>;Database=<db>;UID=<user>;PWD=<pwd>;Encrypt=yes;TrustServerCertificate=yes;"# Access source (example Windows ODBC)ACCESS_CONN_STR="Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=C:\\path\\legacy.accdb;"
5) Target Database Provisioning (One‑Time)
Create Cloud SQL for Postgres instance (v14+), set HA, backups, PITR.
Enable PostGIS and related extensions.
Configure network and access (Cloud SQL Proxy preferred).
6) Schema Deployment
Maintain schema DDLs or alembic migrations in db/schema/.
Example tables with geometry columns for PostGIS.
7) Data Extraction
Access: mdbtools (Linux/macOS) or ODBC via Python (Windows).
SQL Server: pyodbc via Python or bcp for large exports.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
5) Target Database Provisioning (One‑Time)
6) Schema Deployment
db/schema/.geometrycolumns for PostGIS.7) Data Extraction
mdbtools(Linux/macOS) or ODBC via Python (Windows).pyodbcvia Python orbcpfor large exports.8) Transformation & Load (Python + SQLAlchemy)
Implement ETL scripts in
/etl.Directory structure:
8.1 Example ETL Snippets
9) Data Quality & Validation
10) Performance Tuning
VACUUM (ANALYZE).11) Idempotency & Reruns
12) Security & Compliance
13) Dry Run (Non‑Prod)
14) Cutover Plan (Prod)
15) Rollback Plan
16) Post‑Cutover Tasks
17) Example Run Pipeline Skeleton
Sign‑Off
____________________Date:___________________________________Date:___________________________________Date:__________Beta Was this translation helpful? Give feedback.
All reactions