Skip to content

Backup & Restore Strategy

Chiến lược backup toàn diện cho DVDAddin — license, settings, workbook, automation script.

What to backup

4 layers cần backup

LayerTần suấtPhương pháp
Workbook (file Excel dự án)Mỗi save (Ctrl+S)OneDrive sync + weekly archive
License token + settingsSau mỗi cài đặt mới / activateManual copy file + registry export
Templates + master dataKhi updateSync vào shared drive
Custom scripts (VBA, PowerShell)Khi sửaGit repo / cloud folder

Layer 1 — Workbook backup

Mức cơ bản: AutoRecover

Excel có built-in AutoRecover:

  • File → Options → Save → "Save AutoRecover information every" → set 5 phút.
  • Auto save file backup tại %APPDATA%\Microsoft\Excel\.

→ Excel crash → mở Excel lại → có option Recover.

⚠️ Hạn chế: chỉ recover được crash gần nhất, không phải version 1 ngày trước.

Mức trung: OneDrive / Google Drive sync

Lưu dự án trong folder OneDrive:

C:\Users\<user>\OneDrive\Projects\MHC_Van_Phong\

Mỗi save Ctrl+S → tự upload Cloud trong vài giây.

OneDrive có Version History (right-click file → Version history) — restore version cũ.

Mức cao: Weekly archive

PowerShell script chạy mỗi cuối tuần:

powershell
$src = 'D:\Projects\MHC_Van_Phong'
$dst = "D:\Backup\MHC\$(Get-Date -Format 'yyyy-MM-dd').zip"

Compress-Archive -Path "$src\*" -DestinationPath $dst -Force

# Optional: upload to S3 / cloud
# aws s3 cp $dst s3://my-bucket/backup/

Schedule: Task Scheduler → Weekly Sunday 11PM.

→ Mỗi tuần 1 file zip → giữ 8 tuần gần nhất.

Mức cao nhất: Off-site backup

Cho dự án quan trọng (giá trị > 100 tỷ):

  • Backup local + Cloud + ổ cứng vật lý đặt ở văn phòng khác.
  • 3-2-1 rule: 3 copies, 2 different media types, 1 off-site.

Layer 2 — License + DVDAddin settings backup

License token

%LocalAppData%\DVDAddin\license.dat

Backup:

powershell
$src = "$env:LOCALAPPDATA\DVDAddin\license.dat"
$dst = "$env:USERPROFILE\Documents\Backup\DVDAddin\license.dat.bak"

New-Item -ItemType Directory -Path (Split-Path $dst) -Force | Out-Null
Copy-Item $src $dst -Force

Registry settings

Export:

powershell
$dst = "$env:USERPROFILE\Documents\Backup\DVDAddin\settings.reg"
reg export "HKCU\Software\DVD\DVDAddin" $dst /y

→ File .reg import được vào máy khác / sau cài lại Windows.

Restore script

powershell
# Restore license
Copy-Item "$env:USERPROFILE\Documents\Backup\DVDAddin\license.dat.bak" `
          "$env:LOCALAPPDATA\DVDAddin\license.dat" -Force

# Restore settings
reg import "$env:USERPROFILE\Documents\Backup\DVDAddin\settings.reg"

# Restart Excel
Get-Process EXCEL -ErrorAction SilentlyContinue | Stop-Process -Force
& 'C:\Program Files\Microsoft Office\root\Office16\EXCEL.EXE'

⚠️ Lưu ý: License token chỉ restore được trên CÙNG máy (cùng MachineGuid). Đổi máy → phải Activate lại với email/password.

Lang preference

%APPDATA%\DVDAddin\lang.txt

File text 2-3 byte (vi hoặc en) — backup nhỏ, copy như license.

Layer 3 — Templates + master data

Folder structure

\\Cloud\DVDAddin_Master\
├── Templates\
│   ├── BBNT_Template.docx
│   ├── HopDong_Template.docx
│   ├── NhatKy_Template.docx
│   └── DuToan_Template.xlsx
├── MasterData\
│   ├── BangGia_2026.xlsx
│   ├── DanhMucCongTac.xlsx
│   ├── DinhMucNhanCong.xlsx
│   └── Holidays_VN.xlsx
└── Scripts\
    ├── deploy-team.ps1
    ├── backup-license.ps1
    └── auto-archive.ps1

Sync vào Cloud (OneDrive Business / Google Drive Workspace) → toàn team access.

Version master data

Khi update bảng giá:

  1. Save current → BangGia_2026_v1.xlsx.
  2. Edit → save → BangGia_2026_v2.xlsx.
  3. Set name "current" symlink hoặc BangGia_2026.xlsx (luôn point version mới nhất).

Workbook con tham chiếu BangGia_2026.xlsx (không có version suffix) → tự lấy version mới.

Connect Server backup

Nếu dùng Connect Server:

  • Server lưu data trên Cloudflare D1 (auto-backup hàng ngày bởi Cloudflare).
  • User-side: sau mỗi sync, save snapshot local trong %LocalAppData%\DVDAddin\Sync\.

→ Backup automatic cả 2 phía.

Layer 4 — Custom scripts

VBA macros

Workbook chứa VBA → backup workbook = backup macro.

Để extract macro standalone:

  • Excel: Developer → Visual Basic → File → Export File → save .bas / .cls.
  • Lưu vào folder Scripts\VBA\.

PowerShell automation scripts

Scripts đều ở folder Scripts\ shared drive.

Git version control:

bash
cd \\Cloud\DVDAddin_Master\Scripts
git init
git add .
git commit -m "Initial backup"

Mỗi sửa script → git commit → có history.

Auto Click sequences

DVDAddin Auto Click sequences .dvdac files lưu manual hoặc:

  • %APPDATA%\DVDAddin\AutoClick\ (default folder).
  • Backup folder này cùng license.

Disaster recovery scenario

Scenario 1: Máy hỏng cứng — không khởi động Windows

Restore steps:

  1. Mua máy mới / cài lại Windows.
  2. Cài Excel + DVDAddin (setup.exe phiên bản mới nhất).
  3. Restore từ backup:
    • license.dat%LocalAppData%\DVDAddin\license.dat. Tuy nhiên license này tied to old MachineGuid → chỉ work khi clone HDD từ máy cũ. Nếu máy mới hoàn toàn → phải Activate lại bằng email/password.
    • settings.regreg import → restore Preferences + API keys.
  4. Restore workbook từ Cloud / archive zip.
  5. Test: mở Excel → DVD Addin tab → Bản quyền → Sign in lại nếu cần.

Time to recover: 30-60 phút nếu có backup tốt.

Scenario 2: Ransomware encrypt file

Worst case:

  • File workbook bị encrypt → mất hết data nếu không pay ransom.
  • Backup local cũng có thể bị encrypt cùng.

Mitigation:

  • Backup off-site / cloud (ransomware không reach).
  • OneDrive Version History có thể restore version trước encrypt.

Scenario 3: Excel update breaks DVDAddin

Microsoft đôi khi update Excel làm DVDAddin (hoặc add-in khác) crash.

Fix:

  • Tạm tắt DVDAddin (File → Options → Add-ins → uncheck).
  • Đợi DVDAddin release patch (thường 1-2 tuần sau Excel update).
  • Trong lúc đó workbook vẫn mở được, chỉ thiếu DVDAddin features.

Prevention:

  • Disable Microsoft Update auto trong môi trường production critical.
  • Test Excel update trên máy ảo trước khi deploy team.

Backup automation

All-in-one backup script

powershell
# backup-all.ps1
$ErrorActionPreference = 'Stop'
$today = Get-Date -Format 'yyyy-MM-dd'
$backup_root = "D:\Backup\$today"

New-Item -ItemType Directory -Path $backup_root -Force | Out-Null

# 1. License
Copy-Item "$env:LOCALAPPDATA\DVDAddin\license.dat" "$backup_root\license.dat" -ErrorAction SilentlyContinue

# 2. Registry
reg export "HKCU\Software\DVD\DVDAddin" "$backup_root\settings.reg" /y

# 3. Lang
Copy-Item "$env:APPDATA\DVDAddin\lang.txt" "$backup_root\lang.txt" -ErrorAction SilentlyContinue

# 4. Workbook projects
$projects = 'D:\Projects'
if (Test-Path $projects) {
    Compress-Archive -Path "$projects\*" -DestinationPath "$backup_root\projects.zip" -Force
}

# 5. Templates + Scripts
$cloud = '\\Cloud\DVDAddin_Master'
if (Test-Path $cloud) {
    Compress-Archive -Path "$cloud\*" -DestinationPath "$backup_root\master.zip" -Force
}

# 6. Cleanup old backup (keep 8 weeks)
Get-ChildItem 'D:\Backup' -Directory |
    Where-Object { $_.LastWriteTime -lt (Get-Date).AddDays(-56) } |
    Remove-Item -Recurse -Force

Write-Output "Backup done at $backup_root"

Schedule

Task Scheduler:

  • Trigger: Weekly Sunday 11PM.
  • Action: PowerShell -File D:\Scripts\backup-all.ps1.
  • Settings: Run whether user logged on or not. Wake computer if needed.

Notification on failure

Add email notification to script:

powershell
try {
    # backup logic
} catch {
    Send-MailMessage -To '[email protected]' -Subject 'Backup FAILED' `
                     -Body $_.Exception.Message -SmtpServer 'smtp.company.com'
}

Restore checklist

Khi restore vào máy mới:

  • [ ] Cài Windows + Excel + DVDAddin.
  • [ ] Restore license.dat.
  • [ ] Import settings.reg.
  • [ ] Restore lang.txt.
  • [ ] Map shared drive \\Cloud\DVDAddin_Master\.
  • [ ] Open Excel → verify DVD Addin tab hiện.
  • [ ] Bản quyền → verify "Activated" status.
  • [ ] Test 1 lệnh free (Smart Case).
  • [ ] Test 1 lệnh premium (Translate Gemini).
  • [ ] Restore workbook from cloud / archive.

→ Done: máy mới giống y hệt máy cũ.

Liên quan

Released under DVDAddin License.