Design a Database Backup Service
Problem Statement
π‘ βDesign a Database Backup Serviceβ
This question fits perfectly for companies like Nutanix, AWS, or Google Cloud, where backup, reliability, and distributed system thinking are key.
π§ LLD Problem Statement β Design a Database Backup Service
π― Objective
Design a Database Backup Service that can periodically take backups of databases, store them securely, manage versions, and allow easy recovery when needed.
The service should support automated scheduling, incremental backups, and failure recovery β similar to how cloud database services like AWS RDS or Nutanix Era manage backups.
π§© Context
Modern systems rely on database backups for disaster recovery and data durability.
Your goal is to design a modular, class-based system that manages backup creation, scheduling, and storage for different databases (e.g., MySQL, PostgreSQL, MongoDB).
This is a Low-Level Design (LLD) problem focusing on classes, components, and interactions, not infrastructure.
β Functional Requirements
βοΈ Non-Functional Requirements
AspectDescription
Reliability
No data corruption; ensure restore consistency.
Extensibility
Should support new database types easily.
Scalability
Handle multiple concurrent backup jobs.
Fault Tolerance
Retry failed backups; recover gracefully.
Maintainability
Follow SOLID principles with clear abstractions.
π§± Core Classes / Components
ClassResponsibility
Database
Abstract class representing a database instance.
MySQLDatabase / PostgreSQLDatabase
Concrete implementations with DB-specific backup logic.
BackupJob
Represents a single backup execution with status tracking.
BackupScheduler
Schedules recurring backups.
BackupManager
Orchestrates backup creation, deletion, and restoration.
BackupStorage
Interface to store and retrieve backup files.
LocalStorage / CloudStorage
Concrete implementations for storage targets.
NotificationService
Sends alerts for backup failures or completions.
π§Ύ Class Diagram (Text Representation)
1
2ββββββββββββββββββββββββββ
3β Database β
4ββββββββββββββββββββββββββ
5β + id: String β
6β + name: String β
7β + connectionString: String β
8ββββββββββββββββββββββββββ
9β + createBackup(type): BackupJob β
10β + restore(backup: BackupJob): void β
11βββββββββββββββ¬βββββββββββ
12 β
13 ββββββββββββββ΄ββββββββββββββ
14 β β
15 βΌ βΌ
16MySQLDatabase PostgreSQLDatabase
17
18ββββββββββββββββββββββββββ
19β BackupJob β
20ββββββββββββββββββββββββββ
21β + id: String β
22β + databaseId: String β
23β + type: BackupType β
24β + status: BackupStatus β
25β + timestamp: Date β
26β + filePath: String β
27ββββββββββββββββββββββββββ
28β + start(): void β
29β + markCompleted(): void β
30β + markFailed(): void β
31ββββββββββββββββββββββββββ
32
33ββββββββββββββββββββββββββ
34β BackupManager β
35ββββββββββββββββββββββββββ
36β + storage: BackupStorage β
37ββββββββββββββββββββββββββ
38β + triggerBackup(db): BackupJob β
39β + restoreBackup(db, backup): void β
40β + listBackups(db): List<BackupJob> β
41ββββββββββββββββββββββββββ
42
43ββββββββββββββββββββββββββ
44β BackupStorage (IF) β
45ββββββββββββββββββββββββββ
46β + save(backup): void β
47β + load(backupId): File β
48βββββββββββββββ¬βββββββββββ
49 β
50 ββββββββββββββ΄βββββββββββββ
51 β β
52 βΌ βΌ
53LocalStorage CloudStorage
54
55ββββββββββββββββββββββββββ
56β BackupScheduler β
57ββββββββββββββββββββββββββ
58β + schedule(db, interval): void β
59β + runPending(): void β
60ββββββββββββββββββββββββββπ Example Flow
π§ Design Discussion Points
π§© Design Patterns Used
PatternPurpose
Factory Method
For instantiating different Database subclasses (MySQL, PostgreSQL).
Strategy Pattern
For different storage types (Local, Cloud).
Template Method
Common backup flow with database-specific steps.
Observer Pattern
Notify users of backup completion/failure.
Command Pattern
Encapsulate backup/restore operations.
βοΈ Example Scenario
1
2Database: MySQL (employees_db)
3Schedule: Every 6 hours
4Backup Type: Incremental
5
6π 12:00 PM β Full backup created: employees_db_full_12pm.bak
7π 06:00 PM β Incremental backup created: employees_db_inc_6pm.bak
8π 12:00 AM β Incremental backup created: employees_db_inc_12am.bak
9
10Backup Metadata:
11{
12 "db": "employees_db",
13 "backups": [
14 {"id": 101, "type": "FULL", "status": "SUCCESS"},
15 {"id": 102, "type": "INCREMENTAL", "status": "SUCCESS"}
16 ]
17}β Final Summary
Problem Statement:
Design a Database Backup Service that can schedule, execute, and manage backups for multiple databases.
The service should support full and incremental backups, configurable intervals, and failure handling with storage abstraction.
π Bonus Extensions (if interviewer asks for depth)