Backup & Restore (legacy)
Procedures for database backup and restore operations on the legacy estate.
Backup Overview
Automatic Backups
Azure SQL provides automatic backups:
| Backup Type | Frequency | Retention |
|---|---|---|
| Full | Weekly | 7-35 days (configurable) |
| Differential | Every 12-24 hours | Same as full |
| Transaction Log | Every 5-10 minutes | Same as full |
Manual Backups
For migrations or major changes, create manual backups.
Creating Manual Backup
Via Azure Portal
- Go to Azure Portal → SQL Database
- Select database (ESHARS)
- Click “Export”
- Configure:
- Storage account
- Container
- File name:
ESHARS_YYYYMMDD_manual.bacpac - Authentication
- Click “OK”
- Monitor export progress
Via Command Line
# Using SqlPackageSqlPackage.exe /Action:Export \ /SourceConnectionString:"Server=tcp:server.database.windows.net;Database=ESHARS;..." \ /TargetFile:"ESHARS_20240115.bacpac"Point-in-Time Restore
When to Use
- Accidental data deletion
- Data corruption
- Testing with production data snapshot
Procedure
- Go to Azure Portal → SQL Database
- Click “Restore”
- Select “Point-in-time”
- Choose restore point (date/time)
- Enter new database name:
ESHARS_Restored_YYYYMMDD - Click “Review + Create”
- Wait for restore to complete (may take hours for large DBs)
Post-Restore
- Verify restored database
- If replacing production:
- Rename current:
ESHARS→ESHARS_Old_YYYYMMDD - Rename restored:
ESHARS_Restored→ESHARS - Update connection strings if needed
- Restart application
- Rename current:
Restore from BACPAC
Via Azure Portal
- Go to Azure Portal → SQL Server
- Click “Import database”
- Select storage account and BACPAC file
- Configure:
- Database name
- Pricing tier
- Collation
- Click “OK”
Via Command Line
# Using SqlPackageSqlPackage.exe /Action:Import \ /TargetConnectionString:"Server=tcp:server.database.windows.net;..." \ /SourceFile:"ESHARS_20240115.bacpac"Disaster Recovery
Geo-Replication
For critical databases, enable geo-replication:
- Go to SQL Database → Geo-Replication
- Select secondary region
- Configure (readable secondary if needed)
- Failover is automatic or manual
Failover Procedure
- Assess primary region status
- If unrecoverable:
- Go to secondary database
- Click “Failover”
- Confirm
- Update DNS/connection strings if needed
- Notify stakeholders
Production Database Restore to Other Environments
Procedure for restoring the production database to Regression, QA, UAT, or Training environments.
Pre-Restore: Capture Environment Settings
Before starting, capture the current settings of the target environment — these will be overwritten by production values.
- EDI Settings — Log into the target environment (e.g., Regression), go to Location → Texas State → Data Mgmt → State Data → System Settings → EDI Settings. Screenshot all field values.
- Pricing Tier — In Azure Portal, note the current pricing tier/DTU settings for the target database.
- Notify Team — Inform the team to stay out of the environment being restored.
Run the Restore
| Target Environment | Azure Automation Runbook |
|---|---|
| Regression | ar-eshars-regressiondb-copy |
| UAT | ar-eshars-uatdb-copy |
| QA | aa-eshars-prod-to-qa-scrub |
- Go to Azure Portal → Automation Accounts → aa-eshars-prod
- Navigate to Runbooks → select the appropriate runbook
- Click Start → OK
- Wait for completion (~15 minutes)
Post-Restore Steps
-
Restore EDI Settings — Log back into the restored environment and re-enter the EDI Settings from your screenshots. Use the full FTP paths (not just the environment name portion):
- PROD:
PROD-4deefb1ce5d3 - QA:
QA-cbe96e528e40 - UAT:
UAT-c5718067b559 - REGRESSION:
REGRESSION-14d39416712d
- PROD:
-
Run District Data Restore Scripts — From
HISD/Eshars.DBUpgrader/SQL/APP/OneTimeRun:- Run
1.3.63.2-DFP-SuccessED-HM-51756.SQL— execute the DELETE on line 1 first, then set the environment value on line 2 - Run
1.3.78.0-SuccessED.sql— execute the DELETE on line 4 first, then set the environment on line 5 - Run
1.3.69.0-Logfiles-HM-5558.sql— execute the DELETE on line 4 first, then set the environment on line 5
- Run
-
Reset Pricing Tier — In Azure Portal, find the restored database → Pricing Tier → adjust DTUs back to the pre-restore setting
-
Verify Database Sizes Match — Confirm the restored database is the same size as production
-
Verify TMHP Service — Ensure the TMHP service is running in the restored environment
Verification
After any restore:
- Connect to restored database
- Verify table counts
- Check recent data
- Test application connectivity
- Run smoke tests
Backup Schedule
| Database | Manual Backup | Retention |
|---|---|---|
| ESHARS | Before major releases | 90 days |
| ESHARSAUDIT | Monthly | 1 year |
| ESHARSLOGS | Quarterly | 6 months |
Last reviewed: [Date]