Lab 14: Point-in-Time Recovery
Overview
Step 1: MySQL — Enable Binary Logging for PITR
docker run -d --name mysql-lab \
-e MYSQL_ROOT_PASSWORD=rootpass \
-e MYSQL_DATABASE=shopdb \
mysql:8.0 \
--server-id=1 \
--log-bin=mysql-bin \
--binlog-format=ROW \
--expire_logs_days=7
for i in $(seq 1 30); do docker exec mysql-lab mysql -uroot -prootpass -e "SELECT 1" 2>/dev/null && break || sleep 2; done
# Verify binary logging
docker exec mysql-lab mysql -uroot -prootpass -e "
SHOW VARIABLES LIKE 'log_bin%';
SHOW VARIABLES LIKE 'binlog_format';
SHOW BINARY LOGS;
"Step 2: Create Baseline Data and Full Backup
Step 3: Simulate Normal Operations and Then "Accidental" Deletion
Step 4: MySQL PITR — Identify Recovery Point in Binary Logs
Step 5: MySQL PITR — Restore to Point Before Disaster
Step 6: PostgreSQL — Configure WAL Archiving for PITR
Step 7: PostgreSQL PITR — Create Data, Backup, Simulate Disaster
Step 8: Capstone — PostgreSQL PITR Restore
Summary
Component
MySQL
PostgreSQL
Key Takeaways
Last updated
