# Frontend backups

Frontend Backup is an Admin-only LaysanX Web module at **Client Admin > Backup**. It saves frontend theme code for a selected built-in theme or a published uploaded theme. It is not a full-site or database backup.

## Create and inspect a backup

1. Open **Client Admin > Backup** and select **Quick backup**, or wait for an automatic snapshot.
2. Find the version in the list. Its name uses `projectname_yyyyMMdd_HHmmssfff` in UTC; the list also shows the theme, backup type, file count, and UTC creation time.
3. Select **View code** to browse a read-only file list and inspect the saved HTML, Razor, CSS, JavaScript, or JSON. The preview never executes saved code.

The worker checks every ten minutes while the client app is running. Each eligible client gets an automatic snapshot when at least six hours have elapsed since its last automatic snapshot. Quick and pre-restore backups do not reset that schedule. If the app is stopped, missed intervals are not backfilled; the next worker pass creates one snapshot.

## Restore a version

Select **Restore** on the chosen backup and confirm. The module first saves a **Before restore** snapshot of the currently active frontend so the operation can be reversed. Restore does not change CMS content, forms, section settings, orders, or binary assets.

| Theme type | What is saved | What restore does |
|---|---|---|
| Uploaded | Tenant-owned `.html`, `.css`, `.js`, and `.json` files, including `theme.json` | Replaces code in the original uploaded theme, synchronizes its manifest metadata, and activates that theme. The original theme record and folder must still exist; blocked themes cannot be restored. |
| Built-in | Deployed Razor source and public CSS/JavaScript, where available | Reselects the built-in theme for the client. It never overwrites shared application files. |

For built-in themes, restoring an old backup **does not roll back a newer server deployment**. On compiled-only deployments, a built-in snapshot may have no viewable source files but can still restore the theme selection. For uploaded themes, restored code may reference images or fonts that have since been removed; those assets must be repaired separately.

## Production storage and release checks

Snapshots default to `App_Data/frontend-backups` under the client app content root. Set `FrontendBackup:StoragePath` to an absolute, private, persistent directory in production, for example with the `FrontendBackup__StoragePath` environment variable. Keep it outside `wwwroot`, provide write permission to the client app service, and preserve it across application publishes. The default path is excluded from Git and publish output.

There is no automatic retention or pruning. Monitor disk usage and back up this directory at the infrastructure level. This feature does not replace PostgreSQL or asset backups.

For an existing SaaS installation, apply `docs/sql/frontend-backup-marketing-postgres.sql` once to add the editable homepage feature block and LaysanX Web product feature card. It does not contain client backup data. New installations receive the same marketing content from the canonical SaaS SQL script and product defaults.

Before release, build the client and SaaS apps, create and preview a quick backup for one uploaded and one built-in theme, restore a test uploaded theme and confirm its frontend renders, confirm built-in restore changes only that client's selection, and verify another tenant cannot view or restore those backups. Check the six-hour worker behavior after the service restarts and confirm the storage path persists across deployments.
