How to Configure Windows Sandbox Local Litestream SQLite Replication via XML in Windows 11

Modern edge backends and embedded databases increasingly run SQLite in production, relying on continuous WAL (Write-Ahead Log) streaming tools—such as Litestream—to replicate changes in real time to S3-compatible object storage. Testing Litestream disaster recovery restorations, WAL replication lag, and snapshot verification directly on a developer workstation can leave lingering lock files, background replication daemons, and database clutter. In Windows 11, Windows Sandbox provides a pristine, isolated testing platform. By authoring custom Windows Sandbox XML (.wsb) configuration files, you can deploy an automated Litestream replication pipeline in seconds.

Architecture of the Disposable Litestream Sandbox

Windows Sandbox provides a disposable, hypervisor-isolated guest environment that resets completely upon termination. To provision an automated Litestream instance, the architecture requires:

  • A mapped host folder: A directory containing the portable litestream.exe binary, a test SQLite database, and replication configuration YAML files.
  • A WSB configuration file: An XML blueprint that mounts the mapped directory and initiates the replication agent automatically via LogonCommand.

Authoring the Windows Sandbox WSB Blueprint

Create a working directory on your host machine, such as C:\SandboxLitestream. Download the Windows binary of Litestream into this directory, then create RunLitestream.wsb with the following XML code:

<Configuration>
  <VGpu>Default</VGpu>
  <Networking>Default</Networking>
  <MappedFolders>
    <MappedFolder>
      <HostFolder>C:\SandboxLitestream</HostFolder>
      <SandboxFolder>C:\LitestreamFiles</SandboxFolder>
      <ReadOnly>false</ReadOnly>
    </MappedFolder>
  </MappedFolders>
  <LogonCommand>
    <Command>powershell.exe -ExecutionPolicy Bypass -NoExit -File C:\LitestreamFiles\Start-Litestream.ps1</Command>
  </LogonCommand>
</Configuration>

Authoring Litestream Configuration and Startup Script

Inside the mapped host folder (C:\SandboxLitestream), create a configuration file named litestream.yml:

dbs:
  - path: C:\LitestreamFiles\data\app.db
    replicas:
      - type: file
        path: C:\LitestreamFiles\replica_storage

Next, create the automated PowerShell initialization script named Start-Litestream.ps1:

Write-Host "=============================================" -ForegroundColor Cyan
Write-Host " Starting Litestream SQLite Replication...   " -ForegroundColor Green
Write-Host " DB Path:    C:\LitestreamFiles\data\app.db  " -ForegroundColor Yellow
Write-Host " Replica:    C:\LitestreamFiles\replica_storage " -ForegroundColor Yellow
Write-Host "=============================================" -ForegroundColor Cyan

# Ensure directories exist
New-Item -Path "C:\LitestreamFiles\data" -ItemType Directory -Force | Out-Null
New-Item -Path "C:\LitestreamFiles\replica_storage" -ItemType Directory -Force | Out-Null

# Initialize SQLite database with sample table
Set-Location "C:\LitestreamFiles"
& "C:\LitestreamFiles\litestream.exe" replicate -config "C:\LitestreamFiles\litestream.yml"

Running and Validating Replication in the Sandbox

Double-click RunLitestream.wsb on your Windows 11 host. Windows Sandbox boots up, mounts the mapped folder, and immediately launches Litestream inside an interactive PowerShell window.

Litestream establishes continuous WAL monitoring. In a second PowerShell console inside the sandbox, execute write transactions against app.db using SQLite tools. Notice that Litestream captures each WAL commit and writes encrypted, compressed snapshot chunks to the replica directory in real time.

You can simulate disaster recovery by deleting app.db and executing litestream restore to verify point-in-time recovery. When testing concludes, closing the sandbox window instantly eliminates all WAL files, database replicas, and background replication processes, leaving your host workstation completely clean.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.