Config Backup
Overview
Config Backup lets you export SamWaf's configuration into a single encrypted .samwafconfig archive and restore it onto another device—or across database engines (SQLite, MySQL, PostgreSQL)—with a read-only dry-run preview, atomic database commit, and zero-gap hot reload.
At the top of the page, a two-way radio switcher lets you choose the right migration method while hiding unrelated controls:
- Method 1: Config-Only Migration (Default) — Export and import selected configuration modules via
.samwafconfig. Best for clean new-device setup, copying rules/CC/sites, or migrating between SQLite, MySQL, and PostgreSQL. - Method 2: 100% Full Server Migration — Stop SamWaf and copy the entire SamWaf directory to the same directory path on the target server. Best when you want to preserve 100% of logs, statistics, admin accounts/2FA, application management,
conf/config.yml, and local keys as-is.
Prerequisites
- Accessible only to Super Administrators via an authenticated admin console session (OpenAPI Keys are not accepted).
- Exporting and importing require a backup passphrase of at least 8 characters. The passphrase is never stored on the server and cannot be recovered if lost.
How to Use
Open System Settings → Config Backup and pick a migration method at the top:
Method 1: Config-Only Migration (.samwafconfig One-Click)
When Method 1 is selected, three tabs appear below: Export Config, Import Config, and Local Rollback Snapshots.
1. Export Config
- Choose a Preset:
- Standard Security Migration (Recommended): Sites, routes, custom rules, CC protection, allow/block lists, system settings, tunnels, and host guard (without private keys or credentials).
- Full Config Migration (Secrets): All 7 groups including SSL private keys, ACME orders, DNS credentials, notification secrets, and Access authentication.
- Rules & CC Only (Template): Custom rules, multi-rule CC, IP/URL allow/block lists, IP groups, sensitive words, and URL privacy protection.
- Custom Selection: Pick any modules below with live record counts from the current instance.
- Review Modules & Exclusions: Review the 7 configuration groups and optionally expand the 5 excluded categories that are never exported or imported.
- Configure Encryption & Passphrase:
- Optionally disable Include Secret Fields to blank sensitive system items and CDN credentials on export;
- Enter and confirm a Backup Passphrase (minimum 8 characters; encrypts the archive using Argon2id + AES-256-GCM with the raw
manifest.jsonheader bound as GCM AAD); - Optionally add a Note (stored in the plaintext manifest header for identification—do not put secrets there).
- Click Export .samwafconfig to generate and download the encrypted archive.
2. Import Config (3-Step Wizard)
Import runs through Upload & Unlock → Dry-Run Preview → Apply & Reload. Nothing on the target instance is modified until you confirm the final dialog:
- Step 1: Upload & Unlock
- Pick a local
.samwafconfigfile (up to 32 MB). SamWaf inspectsmanifest.jsonread-only and shows the source SamWaf version, export timestamp, module/record totals, and note; - Enter the backup passphrase and click Unlock & Preview.
- Pick a local
- Step 2: Dry-Run Preview
- Choose Import Mode:
- Replace (Recommended for New Device): Clears existing target rows only for the selected modules before writing; unselected modules remain untouched.
- Merge (Incremental): Keeps existing target records and matches by business key; conflicting entries can be set to Skip (Keep Target) or Overwrite (Use Backup).
- Review Per-Module Plan: Inspect backup counts, current counts, planned actions, and schema/security notes (such as newer-version columns automatically ignored, orphan site-scoped records skipped, or entries sanitized by target security policy).
- Click Confirm Import, review the summary dialog, and click Confirm & Import Now.
- Choose Import Mode:
- Step 3: Apply & Reload
- Automatically saves a local target-key encrypted rollback snapshot under
data/config_backups/before writing; - Remaps
user_codeand the global host UUID to the target instance and re-encrypts sensitive fields with the target instance key; - Commits all writes in a single database transaction (automatic rollback on any error), then runs a zero-gap hot reload across all subsystems without interrupting active traffic ports.
- Automatically saves a local target-key encrypted rollback snapshot under
3. Local Rollback Snapshots
Before every import, SamWaf automatically stores a local key-encrypted snapshot of the pre-import configuration under data/config_backups/ (retaining the latest 5 snapshots).
- If an imported configuration behaves unexpectedly, open Local Rollback Snapshots and click Rollback next to a snapshot to restore it atomically and hot-reload;
- Older snapshots can also be deleted manually.
Method 2: 100% Full Server Migration
Selecting Method 2: 100% Full Server Migration hides the Export/Import/Snapshot tabs and displays the focused three-step OS-level migration guide:
- Stop the SamWaf service on the source server: Gracefully stop the Windows service, systemd unit, or container so SQLite WAL buffers flush cleanly and databases do not corrupt during copy.
- Copy the entire SamWaf directory to the same path on the target server: Archive or sync the entire SamWaf root directory (binary,
conf/config.yml,data/databases,data/.keys/, etc.) into the same directory path on the new server so absolute paths remain valid. - Start SamWaf on the target server and verify: Admin accounts, 2FA, logs, statistics, sites, rules, certificates, and local settings are preserved 100% as-is. If using external MySQL, PostgreSQL, or Redis, verify network connectivity from the new host.
Backup Scope & Exclusions
7 Included Configuration Groups
| Group | Modules |
|---|---|
| A. Sites & Routing | Websites, site groups, load balancing, path rules, cache rules, web password visit accounts, custom blocking pages |
| B. WAF Rules & CC | Custom protection rules, multi-rule CC, sensitive words, URL privacy protection (LDP), anti-leech / bot policies |
| C. Access Lists & IP Intel | IP groups & items, IP allowlist, IP blocklist, URL allowlist, URL restriction, firewall IP block, threat-intel feeds & exclusions, CDN origin IPs |
| D. System Settings & Policies | System configuration items, global parameters, security operations report settings |
| E. Tunnels & Host Guard | TCP/UDP tunnels & dynamic DNS bindings, remote brute-force guard |
| F. Certificates & Keys (Sensitive) | SSL certificates & private keys, ACME orders, DNS credentials, scheduled batch tasks |
| G. Notifications & Access Auth (Sensitive) | Notification channels & credentials, notification subscriptions, Access auth settings & accounts |
Cross-Version Schema Compatibility
The backup engine dynamically aligns table columns using schema metadata. When a newer version adds or removes columns on an existing configuration table, cross-version export and import automatically intersect common columns without manual edits; unknown columns from a newer version are noted during preview and skipped safely.
5 Excluded Categories (Never Exported / Imported)
The following categories are strictly excluded from .samwafconfig and are never overwritten on the target instance:
- Admin Accounts & Sessions: Admin users, 2FA secrets, active sessions, login history, OpenAPI keys, and OpenAPI call logs.
- Log & Stats Databases: Access logs, security events and payloads, archive shards, daily statistics, and IP tag profiles.
- Runtime Caches & Audit Trails: Threat-intel landed snapshots, security audit logs, notification logs, upgrade notice read states, and task run history.
- Application Management: Managed local application definitions (tightly bound to local executable paths and working directories).
- Local Environment & Key Files:
conf/config.yml(database driver/DSN, admin port, trusted proxies, allowed directory lists) and local encryption keys underdata/.keys/.
Security & Auditing
- Authenticated Encryption:
.samwafconfigis a standard ZIP archive containingmanifest.jsonandpayload.enc. Keys are derived via Argon2id and encrypted with AES-256-GCM with the rawmanifest.jsonbytes bound as GCM AAD, rejecting any tampering upon unlock. - Target Policy Enforcement on Import: Imported entries are validated against the target instance's security boundaries—static site roots must reside in allowed directories, cross-device SSL export paths are automatically cleared, webhook and remote feed URLs are checked against outbound policy, local batch paths are restricted to allowed directories, custom rules are syntax-checked, and catch-all system firewall blocks are rejected.
- Audit Logging: Export, import, and rollback actions are recorded under System Settings → Security Audit without logging passphrases or plaintext secrets.
FAQ
- Can a forgotten backup passphrase be recovered? No. Passphrases are never stored or logged on the server; export a new archive from the source instance if the passphrase is lost.
- Does importing require restarting SamWaf? No. After the atomic database transaction commits, SamWaf hot-reloads settings, host routing, tunnels, firewall allowlists, and threat-intel state without dropping business traffic.
- Can I migrate from SQLite to MySQL or PostgreSQL? Yes.
.samwafconfiguses a database-agnostic format and supports migrating configurations across SQLite, MySQL, and PostgreSQL. - What happens if I import Rules without selecting Websites? Global website rules are imported normally; site-scoped rules whose host does not exist on the target instance are flagged as orphan entries during preview and skipped automatically.
- Why can't non-SuperAdmin accounts or OpenAPI Keys access Config Backup? Because Config Backup reads and replaces core instance-wide security configurations, it is restricted to Super Administrator console sessions.
Update History
| Date | Applies to | Changes |
|---|---|---|
| 2026-12-01 | >v1.3.25-beta.13 (unreleased) | Added the Config Backup page with top-level two-way migration switcher (encrypted .samwafconfig config migration vs. 100% stop-and-copy directory guide), 7 module groups with 4 presets, 5 excluded categories disclosure, dry-run preview, Replace/Merge modes, automatic local encrypted pre-import snapshots with one-click rollback, single-transaction commit, and zero-gap hot reload. |
About "Applies to":
vX.Y.Zmeans the feature is available from that release;> vX.Y.Zmeans it is already in the code but not released yet and ships with the next version.
