Skip to content

Commit 880db10

Browse files
committed
refactor(rds-refresh): clarify terminology - RDS clone, RDS snapshot
- Use 'RDS clone' instead of 'clone' to avoid confusion with DBLab clones - Use 'RDS snapshot' instead of 'snapshot' to avoid confusion with DBLab snapshots - Update description: 'Perform full refresh from RDS/Aurora snapshots (logical mode)'
1 parent f52a5b4 commit 880db10

File tree

3 files changed

+41
-41
lines changed

3 files changed

+41
-41
lines changed

rds-refresh/README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# RDS/Aurora Refresh for DBLab
22

3-
Refresh DBLab from RDS/Aurora snapshots without touching production.
3+
Perform full refresh from RDS/Aurora snapshots (logical mode).
44

55
## Why?
66

@@ -9,11 +9,11 @@ DBLab logical mode runs `pg_dump` against your database. On large databases, thi
99
- **Creates load on production**
1010
- **Requires direct network access** to production
1111

12-
This tool dumps from a **temporary snapshot clone** instead. Production is never touched.
12+
This tool dumps from a **temporary RDS clone** instead. Production is never touched.
1313

1414
```
15-
Production RDS ──snapshot──► Snapshot ──restore──► Temp Clone ──pg_dump──► DBLab
16-
(automated) (deleted)
15+
Production ──RDS snapshot──► RDS Snapshot ──restore──► RDS Clone ──pg_dump──► DBLab
16+
(automated) (temporary)
1717
```
1818

1919
## Quick Start
@@ -62,7 +62,7 @@ docker run --rm \
6262
| `source.dbName` || Database name |
6363
| `source.username` || Database user |
6464
| `source.password` || Password (use `${ENV_VAR}`) |
65-
| `clone.instanceClass` || Clone instance type |
65+
| `clone.instanceClass` || RDS clone instance type |
6666
| `clone.securityGroups` | | SGs allowing DBLab access |
6767
| `clone.subnetGroup` | | DB subnet group |
6868
| `dblab.apiEndpoint` || DBLab API URL |
@@ -160,7 +160,7 @@ aws events put-targets --rule dblab-refresh --targets '[{
160160

161161
## Network
162162

163-
Clone must be reachable from DBLab on port 5432. Same VPC or peered.
163+
RDS clone must be reachable from DBLab on port 5432. Same VPC or peered.
164164

165165
## DBLab Setup
166166

@@ -184,24 +184,24 @@ retrieval:
184184
185185
1. Check DBLab health
186186
2. Find latest RDS snapshot
187-
3. Create temp clone (`dblab-refresh-YYYYMMDD-HHMMSS`)
188-
4. Wait for clone (~15 min)
187+
3. Create RDS clone from RDS snapshot (`dblab-refresh-YYYYMMDD-HHMMSS`)
188+
4. Wait for RDS clone (~15 min)
189189
5. Update DBLab config via API
190190
6. Trigger refresh, wait for completion
191-
7. Delete clone (always, even on error)
191+
7. Delete RDS clone (always, even on error)
192192

193193
## Troubleshooting
194194

195195
| Error | Fix |
196196
|-------|-----|
197197
| No snapshots | Enable automated backups on RDS |
198-
| Clone not accessible | Check security group allows 5432 from DBLab |
198+
| RDS clone not accessible | Check security group allows 5432 from DBLab |
199199
| Config update failed | Verify DBLab endpoint and token |
200200
| Timeout | Increase `dblab.timeout`, check DBLab logs |
201201

202202
## Cost
203203

204-
Clone cost only while running (~2-5 hours):
204+
RDS clone cost only while running (~2-5 hours):
205205
- db.t3.medium: ~$0.35
206206
- db.r5.large: ~$1.20
207207

rds-refresh/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,10 @@ func run(configPath string, dryRun bool) error {
101101
}
102102

103103
func printUsage() {
104-
fmt.Fprintf(os.Stderr, `rds-refresh - Refresh DBLab from RDS/Aurora snapshots
104+
fmt.Fprintf(os.Stderr, `rds-refresh - Perform full refresh from RDS/Aurora snapshots (logical mode)
105105
106106
Avoids pg_dump on production (which holds xmin → bloat). Instead, creates a
107-
temporary clone from snapshot, refreshes DBLab from clone, then deletes clone.
107+
temporary RDS clone from RDS snapshot, refreshes DBLab from it, then deletes it.
108108
109109
USAGE
110110
rds-refresh -config <path> [-dry-run]

rds-refresh/refresher.go

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func (l *DefaultLogger) Debug(msg string, args ...interface{}) {
3535
fmt.Printf("[DEBUG] "+msg+"\n", args...)
3636
}
3737

38-
// Refresher orchestrates the RDS/Aurora clone and DBLab refresh workflow.
38+
// Refresher orchestrates the RDS/Aurora refresh workflow.
3939
type Refresher struct {
4040
cfg *Config
4141
rds *RDSClient
@@ -79,13 +79,13 @@ func NewRefresher(ctx context.Context, cfg *Config, logger Logger) (*Refresher,
7979
// Run executes the full refresh workflow:
8080
// 1. Verifies DBLab is healthy and not already refreshing
8181
// 2. Gets source database info
82-
// 3. Finds the latest snapshot
83-
// 4. Creates a temporary clone from the snapshot
84-
// 5. Waits for the clone to be available
85-
// 6. Updates DBLab config with the clone endpoint
82+
// 3. Finds the latest RDS snapshot
83+
// 4. Creates a temporary RDS clone from the RDS snapshot
84+
// 5. Waits for the RDS clone to be available
85+
// 6. Updates DBLab config with the RDS clone endpoint
8686
// 7. Triggers DBLab full refresh
8787
// 8. Waits for refresh to complete
88-
// 9. Deletes the temporary clone
88+
// 9. Deletes the temporary RDS clone
8989
func (r *Refresher) Run(ctx context.Context) *RefreshResult {
9090
result := &RefreshResult{
9191
StartTime: time.Now(),
@@ -126,54 +126,54 @@ func (r *Refresher) Run(ctx context.Context) *RefreshResult {
126126

127127
r.logger.Info("Source: %s", sourceInfo)
128128

129-
// Step 3: Find latest snapshot
130-
r.logger.Info("Finding latest snapshot...")
129+
// Step 3: Find latest RDS snapshot
130+
r.logger.Info("Finding latest RDS snapshot...")
131131

132132
snapshotID, err := r.rds.FindLatestSnapshot(ctx)
133133
if err != nil {
134-
result.Error = fmt.Errorf("failed to find snapshot: %w", err)
134+
result.Error = fmt.Errorf("failed to find RDS snapshot: %w", err)
135135
return result
136136
}
137137

138138
result.SnapshotID = snapshotID
139-
r.logger.Info("Using snapshot: %s", snapshotID)
139+
r.logger.Info("Using RDS snapshot: %s", snapshotID)
140140

141-
// Step 4: Create temporary clone
142-
r.logger.Info("Creating temporary RDS clone from snapshot...")
141+
// Step 4: Create temporary RDS clone
142+
r.logger.Info("Creating RDS clone from RDS snapshot...")
143143

144144
clone, err := r.rds.CreateClone(ctx, snapshotID)
145145
if err != nil {
146-
result.Error = fmt.Errorf("failed to create clone: %w", err)
146+
result.Error = fmt.Errorf("failed to create RDS clone: %w", err)
147147
return result
148148
}
149149

150150
result.CloneID = clone.Identifier
151-
r.logger.Info("Created clone: %s", clone.Identifier)
151+
r.logger.Info("Created RDS clone: %s", clone.Identifier)
152152

153153
// Ensure cleanup on any exit
154154
defer func() {
155-
r.logger.Info("Cleaning up temporary clone %s...", clone.Identifier)
155+
r.logger.Info("Deleting temporary RDS clone %s...", clone.Identifier)
156156

157157
if deleteErr := r.rds.DeleteClone(context.Background(), clone); deleteErr != nil {
158-
r.logger.Error("Failed to delete clone %s: %v (manual cleanup may be required)", clone.Identifier, deleteErr)
158+
r.logger.Error("Failed to delete RDS clone %s: %v (manual cleanup required)", clone.Identifier, deleteErr)
159159
} else {
160-
r.logger.Info("Successfully deleted temporary clone %s", clone.Identifier)
160+
r.logger.Info("Deleted RDS clone %s", clone.Identifier)
161161
}
162162
}()
163163

164-
// Step 5: Wait for clone to be available
165-
r.logger.Info("Waiting for clone to become available (this may take 10-30 minutes)...")
164+
// Step 5: Wait for RDS clone to be available
165+
r.logger.Info("Waiting for RDS clone (10-30 min)...")
166166

167167
if err := r.rds.WaitForCloneAvailable(ctx, clone); err != nil {
168-
result.Error = fmt.Errorf("clone did not become available: %w", err)
168+
result.Error = fmt.Errorf("RDS clone did not become available: %w", err)
169169
return result
170170
}
171171

172172
result.CloneEndpoint = clone.Endpoint
173-
r.logger.Info("Clone available at: %s:%d", clone.Endpoint, clone.Port)
173+
r.logger.Info("RDS clone ready: %s:%d", clone.Endpoint, clone.Port)
174174

175-
// Step 6: Update DBLab config with clone endpoint
176-
r.logger.Info("Updating DBLab source config with clone endpoint...")
175+
// Step 6: Update DBLab config with RDS clone endpoint
176+
r.logger.Info("Updating DBLab config...")
177177

178178
if err := r.dblab.UpdateSourceConfig(
179179
ctx,
@@ -245,16 +245,16 @@ func (r *Refresher) DryRun(ctx context.Context) error {
245245

246246
r.logger.Info("Source: %s", sourceInfo)
247247

248-
// Check snapshot
249-
r.logger.Info("Finding latest snapshot...")
248+
// Check RDS snapshot
249+
r.logger.Info("Finding latest RDS snapshot...")
250250

251251
snapshotID, err := r.rds.FindLatestSnapshot(ctx)
252252
if err != nil {
253-
return fmt.Errorf("failed to find snapshot: %w", err)
253+
return fmt.Errorf("failed to find RDS snapshot: %w", err)
254254
}
255255

256-
r.logger.Info("Would use snapshot: %s", snapshotID)
257-
r.logger.Info("Would create clone with instance class: %s", r.cfg.Clone.InstanceClass)
256+
r.logger.Info("Would use RDS snapshot: %s", snapshotID)
257+
r.logger.Info("Would create RDS clone with instance class: %s", r.cfg.Clone.InstanceClass)
258258

259259
r.logger.Info("=== DRY RUN COMPLETE - All checks passed ===")
260260

0 commit comments

Comments
 (0)