Infrastructure and disaster recovery: from ransomware to three clouds in five days
Period: September 2026 to date · Role: architecture, operations, restore tests, migrations and disaster drills · Status: in production on an ARM VM on Oracle Cloud in São Paulo since 2026-11-12, with a standby server drilled on 2026-12-05 · Updated: 2026-12-05
One-sentence summary: after ransomware encrypted the group’s physical servers, I rebuilt operations in containers in the cloud, with hourly backups, a copy that not even I can delete, restores proven for real and the ability to switch providers in a single morning, which was done twice in five days.
1. Context and problem
On 2026-09-23, ransomware hit the network of the industrial group I run. The virtualization host was compromised and the virtual machines, including the commercial ERP’s database server, were encrypted. The ERP never came back.
The rebuild started with what brought in revenue: a quoting system with ICMS tax substitution, in production on 2026-09-30, on a VPS with Docker. Then came management accounting, the websites and Asset Tecnologia’s systems. The infrastructure question became a single one: if it happens again tomorrow, what is lost and how long does it take to come back?
The answer required three things: a copy that an attacker with full access cannot delete, a proven (not assumed) restore and independence from any single provider.
2. Results
| Indicator | Today |
|---|---|
| Maximum data loss on critical databases | 1 hour |
| Immutable copy | Object Lock in Compliance mode, 60 days |
| Restore | tested every month, on its own, in a disposable container, with row counts compared to production |
| A backup that fails | sends an email within minutes, through a service outside the servers |
| Copies outside the main provider | three destinations, two of them encrypted, plus a standby server |
| Cutover time to another provider | about 16 minutes, measured on 2026-11-12 |
| System up on the standby from the latest dump (drill) | about 4.5 minutes of machine time, measured on 2026-12-05 |
| Cost of the main server | within Oracle Cloud’s free tier |
3. Backup architecture
flowchart LR
APP[Containers<br/>apps and databases] --> H[pg_dump<br/>hourly<br/>critical databases]
APP --> D[Daily pg_dump<br/>all databases<br/>and configuration]
H --> B2[(Backblaze B2<br/>Object Lock<br/>Compliance 60 days)]
D --> B2
H --> GPG[GPG encryption<br/>private key<br/>outside the cloud]
D --> GPG
GPG --> GD[(Google Drive)]
GPG --> OD[(OneDrive)]
B2 -. read-only key,<br/>restricted to a prefix .-> RES[Standby server]
APP -. databases pulled<br/>every hour .-> RES
- Hourly. Since 2026-11-05, the critical databases (quoting, management accounting and the two Asset systems that hold customer data) are exported every hour. Maximum loss in an outage dropped from 24 hours to 1 hour. Databases that can be reloaded from public sources stay on the daily schedule.
- Immutable. Since 2026-10-07, a copy goes to Backblaze B2 with Object Lock in Compliance mode and 60-day retention. In this mode, not even the owning account can shorten retention or delete the object before it expires.
- Encrypted. Since 2026-11-13, everything that goes to Google Drive and OneDrive is encrypted with GPG. The private key and its passphrase stay outside those clouds.
- Least privilege. The standby server’s key can only read, and only the hourly dumps prefix: it cannot see the configuration bundle, which contains the write keys. Tested: writing with it returns access denied.
4. Tests that prove instead of assume
| Test | Date | Result |
|---|---|---|
| Permanently delete an object in B2 | 2026-10-07 | Denied by the provider. Overwriting created a new version and kept the original |
| Restore the ERP database from B2 | 2026-10-07 and 2026-11-02 | Dump downloaded and restored in a disposable container, with table row counts matching production |
| Restore a new system’s database before opening it to users | 2026-11-05 | New database with the same tables, migrations and reference data |
| Standby key writing outside its scope | 2026-11-06 | Access denied |
| Automatic monthly restore | on the 1st of every month, since 2026-11-20 | Downloads the latest daily dump of each database from B2, restores it in a disposable container and checks: every table in the dump’s index, none empty and no drop above 20% against the previous month. On the PC side, 40 random files per source downloaded and compared byte by byte with the encrypted copy |
| Main server outage drill | 2026-12-05 | A whole system came up on the standby server from scratch, with data matching production (details in section 5) |
Every backup and test job pings an external monitor (Healthchecks.io) when it starts and when it ends. If it fails, or simply does not run, an email goes out. Living outside the servers is the point: the alert goes out even if the main server goes down entirely. The same monitor watches the disk on all three servers, certificate expiry on every domain and, since 2026-12-05, application errors and slowness.
5. Disaster drill: how long it really takes
Until December, the answer to “what if the main server disappeared right now” was an estimate. On 2026-12-05 it became a measurement. I picked the most sensitive system, the accounting SaaS, which stores clients’ encrypted A1 digital certificates, and brought up a full copy on the standby server without touching production or DNS.
flowchart LR
C[Code<br/>production version] --> I[Image built<br/>on the standby]
DU[(Last hour's dump<br/>already on the standby)] --> R[New database<br/>restored]
I --> A[App up<br/>isolated network<br/>external jobs off]
R --> A
A --> V{Check<br/>row counts and<br/>encrypted data}
| Step | Elapsed time |
|---|---|
| Code received and extracted | 14 s |
| Image built (ARM, no cache) | 250 s |
| Database restored from the dump | 261 s |
| Application responding, with login | about 265 s |
- Technical RTO of about 4.5 minutes, 4 of them spent building the image. Adding the time for someone to notice, log in and decide, the realistic target is 30 to 60 minutes.
- RPO of up to 1 hour. The dump used was 47 minutes old. Production’s audit table had 18 more rows than the copy, exactly what happened after the dump; every other main table matched.
- The key kept on the standby opens the encrypted data. All 7 client A1 certificates, file and password, opened with the copy’s configuration. A backup that restores the database but cannot decrypt what is in it is worthless, and you only find out by testing.
- Isolated on purpose. Its own network, a local-only port and every job that talks to the outside turned off: invoice capture from the tax authority, email, notifications and AI. Two installations querying the tax authority at the same time would block the clients’ company IDs.
What the drill found that the documentation did not: the standby server’s configuration file was readable only by the administrator, and the application runs unprivileged (one of the security audit’s fixes). The app came up, but without configuration, answering “no database”. In a real outage, that would have cost diagnosis time at the worst possible moment. The fix became part of the runbook, which now also gives up after 2 minutes with the log on screen instead of waiting forever.
6. Three clouds in five days
The container design, with each system in its own compose file and the data in dumps, was put to the test twice in the same week.
| Date | From | To | Reason | How |
|---|---|---|---|---|
| 2026-11-07 | VPS at Hetzner (Europe) | AWS in São Paulo | Latency: first response dropped from about 0.75 s to 0.05 s, a difference users noticed | System by system, with matching table counts before the DNS switch; about 30 containers; certificates issued in about 1 minute |
| 2026-11-12 | AWS in São Paulo | ARM VM on Oracle Cloud in São Paulo | Zero cost on the ARM free tier, with more memory, keeping data in Brazil | ARM images built on the new server and tested while stopped; at cutover, 9 databases copied with identical row counts, 36 containers, DNS switched and certificates reissued in about 16 minutes |
After the second migration, AWS stayed as a stopped standby with the cutover databases, and a server at Hetzner pulls the production databases every hour. If Oracle goes down, there is somewhere to go back to without relying on the cloud backup.
7. Engineering decisions
- Containers and dumps, not machine images. What must survive is the database and the configuration. Everything else is rebuilt from code. That is why a migration means copying dumps and starting compose files, not cloning disks.
- Immutability in the provider, not in discipline. A copy that depends on nobody deleting it does not protect against whoever took over the server. Compliance mode takes that decision away from everyone, including me.
- A synced cloud folder is not a backup. Drive and OneDrive replicate whatever arrives, encrypted ransomware files included. They became an extra, encrypted copy, not the primary one.
- Measure before migrating. The first migration came from a latency measurement; the second, from a cost and capacity calculation. Neither from brand preference.
- Rehearsed cutover. On Oracle, everything was built and tested with the apps stopped hours before; the cutover was just stop, copy the databases, check and switch DNS.
8. Lessons
- A backup destination failed silently. On 2026-11-02, a check showed that one destination’s authorization had been revoked eight days earlier, after a password change. The other two kept working, the gap was filled, and the lesson stuck: a backup without failure alerts is hope, not a backup.
- Certificates do not always issue by themselves. Reloading the proxy did not issue the certificate for a new domain; restarting it did. It went into the deployment runbook.
- Official servers get it wrong too. A government portal serves its TLS chain without the intermediate certificate. The fix was adding the intermediate as an extra authority, without turning verification off.
- A key on screen is a leaked key. Pasting secrets into a terminal or a screenshot exposed keys twice; all were revoked immediately. Since then, secrets go in through scripts that never display the value.
- A security fix can break recovery. Taking root out of the containers was right, but the standby server kept its configuration readable only by root. Only the drill showed it. Every security change has to go through the recovery path too, not just production.
- Reloading is not applying. A configuration file mounted inside a container stayed pinned to the old version after being copied over, and the reload “succeeded” with the old configuration. Since then, the check reads the file inside the container, not on the server.
9. Next steps
The three steps listed here in November are done: failure alerts for every backup job (2026-11-20), automatic monthly restores (2026-11-20) and the first main server outage drill (2026-12-05). Next:
- Repeat the drill on the other systems with client data (clinics, ERP and the legal product), one runbook per system.
- Drill the last mile: proxy, certificate and DNS switch to the standby, with a test subdomain.
- Redo it every six months and whenever the backup setup changes.
10. Stack
Docker Compose · PostgreSQL 16 · Caddy with automatic certificates · Cloudflare (DNS and proxy) · nginx for static sites · Ubuntu 24.04 on ARM (Oracle Cloud, São Paulo) · ARM standby server at Hetzner · rclone · Backblaze B2 with Object Lock · GPG · Healthchecks.io · cron with a lock against concurrent runs.