Backup and restore¶
What runs automatically¶
- Nightly logical database dump (01:30 local), encrypted on the box with
AES-256 before it is written (
forgesync-<timestamp>.sql.gz.enc), 14-day local retention, copied off-box to your S3 bucket. The dump is opened once with the key right after it is written, so a backup that cannot be restored is reported the same night, not on the day you need it. - Weekly copy of the environment file AND the backup key into your cloud
secrets manager (disaster recovery; write-only from the box). The key
lives at
/etc/forgesync/backup.key(root, 0600) and as the secret<your secret id>-backup-key. - A success marker file the daily verification asserts on: if backups
silently stop, the next
fe:verifyrun says so within a day.
Restore, proven not assumed¶
The restore drill (run on the reference install): dump restored into a scratch database in about 15 seconds, row counts matched live exactly, forward migrations applied cleanly, and the application read the restored data. Your install should repeat this drill after go-live; the procedure is in the operator runbook and takes under ten minutes.
Opening a backup¶
On the box, or anywhere the key has been retrieved from the secrets manager:
openssl enc -d -aes-256-cbc -pbkdf2 -iter 200000 \
-pass file:/etc/forgesync/backup.key \
-in /var/backups/forgesync/forgesync-<timestamp>.sql.gz.enc \
| gunzip | mysql <scratch database>
Dumps written before the encryption change end in .sql.gz and open with
gunzip alone; they age out of local retention within 14 days.
Encryption at rest, the whole picture¶
- Inside the application: customer details on the export queue, the Shopify tokens and the Sage credential are encrypted with the application key.
- The backups: encrypted as above, on every copy.
- The disk: the server must run on encrypted EBS volumes (prerequisites,
section 0).
fe:verifychecks this and fails when a volume attached to the instance is not encrypted.
The order gap, and why it is replayable¶
Orders that arrived between the snapshot and the failure are not in the restored database, and the store will not redeliver them. The replay is:
php artisan forgesync:orders:backfill --from "<snapshot time>" --to "now"
It re-fetches the real orders, books the ones Sage already has as complete (checked against Sage itself, so nothing re-exports twice), and queues only what Sage truly lacks. Effective order loss after a restore: none, provided the replay runs.