Skip to content

Backups

Backups are managed via SQLBak, a backup service installed locally on the web and database servers. It connects to the SQLBak cloud dashboard where automated backup jobs can be created and monitored.

The backup flow: SQLBak creates a backup locally in a temp folder → uploads it to AWS S3 (immutable, primary backup storage) and the Hetzner Storage Box → the Synology NAS pulls a copy each day as an on-premise redundancy layer.

Encryption

All backups are encrypted. The encryption password is stored in the Dashlane collection Critical.


Schedule

Backups run daily at 05:30.


Storage & retention

Storage Retention Purpose
AWS S3 (daily) 30 days Immutable daily backups
AWS S3 (weekly) 90 days Immutable weekly backups
AWS S3 (monthly) 180 days Immutable monthly backups
Hetzner Storage Box 1 month Secondary offsite copy
Synology NAS (daily) 30 days On-premise, fast restore
Synology NAS (monthly) 12 months On-premise long-term copy (last backup of each month)

What is backed up

Type Scope
Database Full dump of all tables
Files All files inside the deployments folder of the Bedrock projects

AWS S3

S3 is the primary backup storage. Backups are stored in the eu-north-1 (Stockholm) region, ensuring data stays within the EU.

Object Lock (WORM)

The S3 bucket uses Object Lock in Compliance mode — a write-once-read-many model that prevents backups from being deleted or overwritten, even by an administrator. This protects against ransomware and accidental deletion.

Default retention is set at the bucket level and enforced on every uploaded object.

Bucket structure

SQLBak uploads all backups to the daily/ folder. An AWS Lambda function (backup-retention-manager) runs automatically on each upload and copies files to weekly/ and monthly/ folders with extended retention where applicable.

db/daily/<brand>/<filename>     → 30 days retention
db/weekly/<brand>/<filename>    → 90 days retention  (copied every Sunday)
db/monthly/<brand>/<filename>   → 180 days retention (copied first Sunday of month)

files/daily/<brand>/<filename>  → 30 days retention
files/weekly/<brand>/<filename> → 90 days retention  (copied every Sunday)
files/monthly/<brand>/<filename>→ 180 days retention (copied first Sunday of month)

Lifecycle Policy

A Lifecycle Policy automatically deletes objects after their retention period has expired. Object Lock prevents early deletion — the Lifecycle Policy only deletes objects once the lock has been lifted.

Folder Deleted after
daily/ 31 days
weekly/ 91 days
monthly/ 181 days

Lambda function

The backup-retention-manager Lambda function triggers on every S3 PUT event and handles the weekly/monthly copy logic. It runs in eu-north-1 and uses a restricted IAM role with only the permissions it needs (s3:GetObject, s3:PutObject, s3:PutObjectRetention).

# Logic summary
if Sunday:
    copy daily → weekly/ with 90 days retention
if first Sunday of month:
    copy daily → monthly/ with 180 days retention

SQLBak configuration

Setting Value
--single-transaction Enabled
--lock-tables Disabled

--single-transaction ensures the database dump is consistent without locking tables, preventing site downtime during backup.


Synology

The Synology NAS is an on-premise backup redundancy layer, independent of Hetzner. Each day at 12:00 it connects to the Hetzner Storage Box and pulls the latest backups. It runs at midday so both database and file backups are finished.

The fetch script is at /var/services/homes/pt/scripts/fetch-backups.sh and runs via the Synology task scheduler.

What is fetched

Type Storage Box path Example file
Database production/db/ bkdk202611200430.7z
Files production/files/<brand>/ elome/wp-uploads202611200748.7z

Backups are stored on the NAS under /volume1/backup with the same folder structure.

On every run the script checks both yesterday and today, and skips files already on the NAS. A day that was missed (e.g. the NAS was offline) is fetched on the next run.

  • If today's backup is not ready yet, it is logged as a warning and fetched on the next run.
  • If yesterday's backup is missing, the run fails (exit code 1) and cleanup is skipped.

Retention

Tier Kept for
All backups 30 days
Last backup of each month 12 months

The backup date is read from the file name, not from when the file was downloaded. Each database and brand is handled separately. If the last day of a month is missing, the latest backup from that month is kept instead.

Cleanup only runs after a successful fetch

If any download fails, no backups are deleted. This prevents the NAS from deleting its last copies when the Storage Box is unreachable for a longer period.

The Synology uses a read-only sub-account on the Storage Box. This means a Synology breach cannot touch the production environment — it only has read access to the backup storage, not to the web or DB servers.

Administration

Access method Details
QuickConnect quickconnect.to — QuickConnect ID: barberklingen
Direct (LAN) http://192.168.1.125:5000

A user account must be created by an administrator before you can log in.


Monitoring

Backup monitoring runs at two levels.

SQLBak sends email notifications on every backup job — both on success and on failure. This covers the daily backup execution itself and is the first line of alerting.

CloudWatch monitors the AWS Lambda function that handles the weekly/monthly copy logic. Notifications are sent via SNS (region eu-north-1) to org-it@subscribed.dk.

Alarm Condition
backup-retention-manager-errors Errors >= 1 for 1 datapoint within 5 minutes
backup-retention-manager-no-invocations Invocations < 1 for 1 datapoint within 1 day

backup-retention-manager-errors normally shows \"Insufficient data\"

The errors alarm evaluates a 5-minute window, but the Lambda only runs once a day (on S3 upload). Outside that window there are no data points to evaluate, so the alarm sits in Insufficient data state — this is expected, not a fault. It only flips to OK or In alarm right after an invocation.


How to restore

Warning

Always double-check the restore destination before confirming. Restoring to the wrong location can overwrite production data.

Compromised site: never restore the full deployments folder

The file backup covers the entire deployments folder — Bedrock core, plugins, themes, vendor/, and web/app/uploads/ together. If a site was compromised (e.g. via a vulnerable plugin), that backup contains the backdoor / web shell too, since it was captured after the compromise.

On Bedrock, only web/app/uploads/ is genuine user data. Everything else — core, plugins, themes, customizations/, vendor/ — is defined in Git and composer.json and can be rebuilt clean. Never restore the full deployments folder to recover from a compromise; that reintroduces the backdoor along with the files you actually needed.

Correct recovery order for a compromised site:

  1. Deploy from Git — trigger a fresh deploy of the main branch via the CI/CD pipeline (subscribed deploy <project> --env production --ref main). This rebuilds core, plugins, themes, and vendor/ from source, with no trace of the injected code.
  2. Restore only web/app/uploads/ — use the "Manual (partial restore)" method below, pulling only the web/app/uploads/ path from a backup that predates the compromise. Do not restore any other path from the file backup.
  3. Restore the database — following the "Restore database" steps below, from a backup that predates the compromise.

See Incident Response for the full containment and eradication process before recovery begins.

Restore files

Overwrites everything

This replaces all files in the project with the backup contents.

  1. Go to sqlbak.com and sign in.
  2. Select the server Web - Production.
  3. Open the Jobs tab → select Production - Files.
  4. In the right panel, pick the backup you want to restore and click the restore icon.
  5. Follow the restore wizard, double-checking the restore location.
  6. Wait for the process to complete and verify the result.

Use this for selective file recovery

  1. Connect to the Hetzner Storage Box via SSH or FTP.
  2. Navigate to /sqlbak/production/files.
  3. Identify and download the backup for the site (usually the most recent).
  4. Decompress the backup locally.
  5. Connect to the production server with an FTP client.
  6. Upload only the files you want to restore to their correct destination.
  7. Wait for the upload to complete and verify the result.

Use this when restoring from weekly or monthly backups

  1. Go to the AWS S3 console.
  2. Navigate to the backup bucket.
  3. Browse to the relevant folder (daily/, weekly/, or monthly/).
  4. Select the file and click Download.
  5. Restore manually via FTP or SQLBak.

Restore database

Data loss

This performs a complete database restore. Any data added after the backup point will be lost.

  1. Go to sqlbak.com and sign in.
  2. Select the server DB - Production.
  3. Open the Jobs tab → select backup - production.
  4. In the right panel, pick the backup you want and click the restore icon.
  5. Follow the restore wizard. Make sure to select the correct target database.
  6. Wait for the process to complete and verify the result.

For further reference: SQL Server Restore Database from Backup — SqlBak Blog


Changelog

November 20, 2026

  • Synology: keeps the last backup of each month for 12 months (in addition to 30 days of daily backups)
  • Synology: fetch-backups.sh updated for the new .7z file names and per-brand folders
  • Synology: fetches yesterday's backups if they were missed, and only cleans up when all downloads succeeded
  • Synology: fetch moved from 08:15 to 12:00 so all backups are ready

June 26, 2026

  • Added AWS S3 as primary immutable backup storage (Object Lock, Compliance mode, eu-north-1)
  • Implemented retention policy: 30 days daily, 90 days weekly, 180 days monthly
  • Deployed Lambda function backup-retention-manager for automated weekly/monthly copy logic
  • Configured S3 Lifecycle Policies for automatic cleanup after retention expiry
  • Enabled --single-transaction and disabled --lock-tables in SQLBak to eliminate backup-related downtime
  • Added CloudWatch alarms and SNS notifications for backup monitoring

November 22, 2023

  • Introduced SQLBak backup procedures
  • Extended backup storage period from 14 → 30 days
  • Removed the legacy cron backup scripts (/etc/cron.daily)
  • Refactored fetch-backups.sh on the Synology

September 6, 2023

  • Replaced push-based backups (web server → Synology) with a pull-based mechanism (Synology → Storage Box)
  • Synology now uses a read-only sub-account on the Hetzner Storage Box
  • Synology retention extended from 7 → 14 days