Skip to main content
18 min read

Restore Drill: We Deleted the App Server and Timed the Way Back With Plakar

Disclosure: This post contains affiliate links. We may earn a commission when you purchase through links in this article.
Restore Drill: We Deleted the App Server and Timed the Way Back With Plakar

We deleted the droplet running a self-hosted Forgejo while a script was writing to it, built a new one from a stock image, and restored it from Plakar 1.2.0-beta.1. Over three drills, the app was serving again a median 5 minutes 20 seconds after the delete call returned, and passed every data check at 6 minutes 1 second. Each drill lost what users wrote after the last database dump: between 4 and 16 minutes of writes, depending on when the incident hit.

The step that changed most between Plakar versions is the file restore. On the same 3.71 GiB of data, Plakar 1.2.0-beta.1 put the files back on the app host over SFTP in a median 104 seconds, against 265 seconds on 1.1.8, over seven interleaved runs each. The slowest 1.2 run was faster than the fastest 1.1.8 run.

This post is the drill as we ran it: the setup, the incident, every phase of the recovery with its time, how we checked that the data was really back, the version comparison and its method, and a runbook you can copy.

Plakar sponsored this post. Every number below comes from a file in the demo repository, and the limits are listed near the end.

TLDR

  • Recovery time: a median 5 min 20 s from the delete call to a serving app (4:51 to 6:00 over three drills), and 6 min 1 s to an app that passed every data check (5:36 to 6:59). Detection and moving traffic come on top.
  • Every data check passed in all three drills: all 1,800 seeded uploads downloaded with the right sha256, every upload row had its file, and git fsck --strict passed on all 61 repositories. The byte-for-byte file and table comparisons are in the benchmark.
  • Where the minutes go (the median drill): new droplet 47 s, Docker and images 82 s, database 10 s, files 171 s, app start 4 s, checks 41 s.
  • Data loss: everything written after the database dump. That was 243, 975 and 324 acknowledged comments (one per second) and 24, 98 and 33 uploads. The files backup runs after the dump, so its 57 to 134 seconds count too.
  • Plakar 1.2.0-beta.1 against 1.1.8, same frozen data, 7 runs each: files over SFTP 265 s to 104 s (2.55x), files to a local disk 49 s to 31 s (1.6x), database no change.
  • No Plakar on the app host. The backup host pulls with pg_dump and SFTP, and restores straight into Postgres and over SFTP with file owners.

Prerequisites

  • Two Linux hosts on a private network: one for the app, one for backups. We used two DigitalOcean s-4vcpu-8gb droplets in Frankfurt.
  • Docker with Compose on the app host.
  • Go 1.26 on the backup host to build Plakar 1.2.0-beta.1 (go install github.com/PlakarKorp/plakar@v1.2.0-beta.1). After the 1.2.0 release, use the release package instead.
  • The Postgres 18 client tools (pg_dump, pg_restore, psql) on the backup host, for Plakar's PostgreSQL integration.
  • About an hour for a first run, most of it seeding the app.

The setup

The app is Forgejo, the self-hosted Git forge, with Postgres 18, in Docker Compose. It is a good test because its state lives in two places that have to agree: the database holds users, issues, comments and the list of uploads, and a data directory holds the Git repositories, the uploaded files and app.ini with the app's secret keys. Restore one without the other, or from different moments, and the app starts but breaks in places.

The backup host pulls. Plakar connects to Postgres over the private network and runs pg_dump through its PostgreSQL integration, then reads /srv/forgejo/data over SFTP. Nothing that backs up or restores runs on the app host, and the app host holds no credential for the store, so losing it, or someone getting root on it, does not touch the backups. We tested that boundary against an AI agent with a stolen token in an earlier post; this one is about getting the app back. The price is that the backup host has root SSH on the app host, because restoring files with their owners needs it. Keep the backup host's own access tight.

The order matters: database first, then files. In this test, users only add uploads, so an upload that lands between the two is in the files snapshot but not in the database, which is harmless. In the other order, the database can list an upload whose file is not in the backup. If your app deletes or rewrites files in place, this order is not enough: stop writes during the backup, or take one snapshot of the database and file volumes at the same moment.

The data comes from a seeded generator: 20 users, 60 repositories with real Git history pushed in small batches (so most objects stay as loose files, like on a busy server), 2,400 issues, 8,159 comments and 1,800 uploads between 64 KiB and 8 MiB. Creating comments through Forgejo's API was slow on this droplet, so we stopped at 8,159 instead of the planned 60,000; the repo documents the exact steps. A rerun gives the same shape, not the same bytes (commit times and IDs differ). On disk that is 17,499 files and 3.71 GiB in the data directory, 88% of the files at or under 64 KiB, and a 30 MiB database dump.

How we checked the restore

We never trust an exit code, ours or Plakar's. A restore counts only when the data says so:

  • Files: a sha256 for every file, and the type and path of every entry, compared with the source. One different line fails the run.
  • Database: per table, the row count and an md5 over every column of every row.
  • App: Forgejo's health check, every one of the 1,800 seeded uploads downloaded through the app with the right size and sha256, every upload row in the database matched to its file on disk, git fsck --strict on every repository, and the seeded counts.
  • Writes: a writer posted one comment per second (and an upload every tenth) during each drill and logged when the server acknowledged it. After the restore we know exactly which acknowledged writes came back.

The drill

All three drills ran Plakar 1.2.0-beta.1. Each went like this, with every step timed by the script:

  1. The writer starts. 20 seconds later the backup runs: database, then files.
  2. We wait. The delays were drawn from a seeded random number between 1 and 15 minutes (179, 872 and 185 seconds), to stand in for "somewhere between two scheduled backups".
  3. The incident: doctl compute droplet delete on the app host. The clock starts when the call returns.
  4. A new droplet, from the stock Ubuntu image. The backup host's SSH key goes on it, as cloud-init would do in production.
  5. Bootstrap: Docker, the compose file, the pinned images, Postgres up and empty. Forgejo stays stopped: started now, it would write a fresh schema and new secret keys.
  6. Plakar restores the database straight into the new Postgres, then the files over SFTP with their owners.
  7. Forgejo starts and passes its health check. The app is serving.
  8. The app checks above run. Only then is the drill a success.

Here is the restore half of drill 1, from results/drill/drill-1/. The two restores ran on the backup host during the drill (our plakar calls also pass -cachedir); the ls ran on the same store afterwards, and the last two commands read the saved logs and the saved result of the app checks.

Results: from delete to verified

Phase Drill 1 Drill 2 Drill 3
New droplet, SSH up 59 s 46 s 47 s
Bootstrap: Docker, images, empty Postgres 103 s 93 s 82 s
Point Plakar at the new host 5 s 5 s 5 s
Restore the database (PostgreSQL integration) 10 s 10 s 10 s
Restore the files (SFTP integration) 109 s 200 s 171 s
Start Forgejo until healthy 5 s 5 s 4 s
Serving 291 s 360 s 320 s
Data checks 45 s 60 s 41 s
Verified 336 s 419 s 361 s
Acknowledged comments lost 243 975 324
Acknowledged uploads lost 24 98 33
Time from the backup to the incident 182 s 874 s 187 s

Times run from the moment doctl compute droplet delete returned. Rows are rounded, so they may not add up to the totals by a second. Source: results/drill/*/events.jsonl and results/summary.json.

What the drills show:

  • The restore was the biggest phase, not the only one. The database and files took 2 to 3.5 minutes of the 5 to 6, and getting a new host with Docker and the images ready took another 2 to 2.7. An image with Docker and the app's images already in it may shorten that second part; we used a stock image on purpose and did not test one.
  • The database restore was the quick part. The PostgreSQL integration ran the globals and pg_restore into the new Postgres in 10 seconds every time, with no dump file to copy around and no pg_restore command to get right at 3 a.m. Our database is small (a 30 MiB dump); a large one moves this line.
  • The file restore varied: 109, 200 and 171 seconds. In the benchmark below, the same restore on a quiet host took 89 to 135 seconds. The droplet seems to matter more than the drill. Restoring the benchmark backup onto drill 3's replacement host later, with nothing else running, took 169 and 176 seconds, the same as during its drill, while a third, just-created droplet took 80 to 90 seconds and the original app host 89 to 135. Same size, same region, different machines underneath. Drill 2's host had lost 13% of its CPU time to the hypervisor (steal) since boot, which may explain its 200 seconds; we measured steal since boot, not during the restore, so that is a likely cause, not a proven one. The benchmark, with interleaved runs, is the better guide to the version difference; the drills show what a whole recovery costs.
  • Every drill passed every data check. All 1,800 seeded uploads matched, no upload row lacked its file, all 61 repositories passed git fsck --strict, and the seeded counts were all there. These are app-level checks; the byte-for-byte comparison of every file and every table row is in the benchmark below.
  • The data loss is everything after the database dump. Each drill lost a contiguous run of acknowledged comments, from just after the dump to the end: 243, 975 and 324 of them. Measured from the last comment that came back to the last one the old app acknowledged, that is 243, 975 and 324 seconds, to about a second. The files backup ran after the dump and took 57, 97 and 134 seconds, so that time is part of the loss. The uploads in that window (24, 98 and 33) are lost to users too. The few that landed before the files backup finished (5, 5 and 10) came back as files on disk, but the database has no record of them, so users cannot see them.
  • The old app kept answering after the delete call returned. In all three drills, it acknowledged writes for about 2 more seconds. Those writes are lost too. Your incident timestamp is not your last write; the writer's log is what told us.

What changed in Plakar 1.2

Plakar runs most integrations (SFTP, S3, PostgreSQL and others) as separate plugin processes and talks to them over gRPC. A few (fs, http, tar, ptar, stdio) are built into the binary. That split is where the 1.2 restore change sits, so it is worth seeing in the code.

In 1.1.8, a restore through a plugin sent every file down one stream, one file at a time: the file's header, then its bytes in 1 MiB chunks, then the next file. The plugin can write several files at once, but it only ever had one file arriving. From the old client (integration-grpc v1.1.2):

for record := range records {
    stream.Send(&hdr)                  // the next file's header
    for {
        n, err := record.Reader.Read(buf)
        sendData(buf[:n])              // its bytes, on the same stream
        if errors.Is(err, io.EOF) { break }
    }
}

1.2.0-beta.1 is the first release on the new integration SDK (integration-sdk v1.1.5). Files under 64 KiB travel inline with their header. Larger files each get their own PutData stream, and a pool of workers the size of Plakar's concurrency setting reads them from the store and sends them in parallel. The plugin side was already ready for it: the SFTP exporter's own code is the same in both builds we used (sftp/v1.1.10 and sftp/v1.1.11), an errgroup that writes up to the concurrency limit at once, apart from a new check that refuses to write below a symlink.

The engine changed too. Plakar 1.2.0-beta.1 pins kloset v1.2.0-beta.2, which includes the restore read path merged into kloset in October 2026: batched blob reads, a restore walk over directory packs with a prefetcher, and background readahead. 1.1.8 pins kloset v1.1.8, which already prefetched and merged some reads, but has none of these three.

So there are two improvements stacked, and the benchmark has a path for each:

  • files-local: restore to a local directory through the built-in fs exporter, which already wrote in parallel in 1.1.8. No plugin transport is involved, so this path shows what changed without it.
  • files-sftp: restore to the app host through the SFTP plugin. The engine and the transport changed.

Plakar 1.1.8 against 1.2.0-beta.1, same data

Before the drills, we stopped Forgejo, backed the same data up once with each version into its own store, and restored each backup seven times, interleaved (1.1.8 first in odd rounds, 1.2.0-beta.1 first in even ones), with the page cache dropped on both hosts before every restore. Same two droplets, same Go 1.26.11 build of both versions, default settings. Every one of the 42 restores matched the source: file checksums for the file paths, table fingerprints for the database.

Restore path Plakar 1.1.8 Plakar 1.2.0-beta.1 Change
Files over SFTP to the app host (plugin) 265.0 s (226.5 to 284.6) 103.9 s (89.2 to 134.7) 2.55x faster
Files to a local directory (built-in fs) 48.9 s (46.2 to 56.2) 30.6 s (29.5 to 45.8) 1.60x faster
Database through the PostgreSQL integration 7.8 s (6.6 to 9.6) 7.6 s (7.2 to 10.4) no difference

Medians of 7 runs, min to max in brackets. The data is 17,499 files and 3.71 GiB; the database dump is one file.

The slowest 1.2.0-beta.1 run (134.7 s) was faster than the fastest 1.1.8 run (226.5 s). In throughput, the SFTP restore went from 14 MiB/s to 37 MiB/s.

The three paths line up with the code:

  • SFTP, 2.55x. Both changes apply here: files now reach the plugin in parallel, and the engine reads them faster. This is the path the drill uses, and it is what most "restore to another machine" setups look like.
  • Local directory, 1.60x. No plugin transport here, so this gain comes from elsewhere in the new version, which fits the new read path in kloset. The fs exporter also changed a little between the versions, and we did not profile to split the gain between them.
  • Database, no change. The backup is one 30 MiB dump file, and pg_restore does the work. Parallel writes across files cannot help one file. A server with many databases gets one dump file per database and could gain; we did not test that.

The backup side moved too, but we ran it once per version, so take it as a hint, not a result: the files backup took 156 s on 1.1.8 and 120 s on 1.2.0-beta.1.

Peak memory did not grow with the parallel path, as far as we measured it: the peak RSS of the restore process (GNU time) was 345 MiB against 341 MiB over SFTP, and 423 MiB against 340 MiB for the local restore. We did not add up the plugin and helper processes separately.

Both versions ran with Plakar's default concurrency, which is the number of CPUs minus one: 3 on these 4 vCPU droplets. So 1.2.0-beta.1 used at most 3 parallel streams for files over 64 KiB.

We tried more workers afterwards, on a fresh droplet of the same size: with -concurrency 12, 1.2.0-beta.1 took a median 84.6 s over 4 runs (67.3 to 89.2), against 80.5 to 90.5 s at the default on the same droplet; 1.1.8 took a median 234.1 s (216.1 to 260.7). In this small comparison, run after the benchmark and not interleaved with the default, we saw no repeatable gain from more workers on 4 vCPU. A larger host or a slower link may behave differently.

Method checks

What we did to keep the comparison fair, and what a skeptical reader should check:

  • Same bytes. Forgejo was stopped during both benchmark backups, and the data directory's manifest was identical before and after them. Each version restored its own backup of that same data, so neither read the other's store format. The store layouts differ, since each version wrote its own.
  • Same build. Both versions were built from their tags with the same Go 1.26.11 toolchain on the backup host. The SFTP and PostgreSQL packages were built from pinned tags of PlakarKorp/integrations: the last tags on the old protocol for 1.1.8 (sftp/v1.1.10, postgresql/v1.1.3) and the first on the SDK for 1.2.0-beta.1 (sftp/v1.1.11, postgresql/v1.1.4). The SFTP exporter's write logic is the same in both, so the transport is what differs.
  • Cold page cache, warm Plakar cache. We dropped the page cache on both hosts before each restore. Plakar's own local cache on the backup host stayed, as it would on a backup server that survives the incident.
  • Interleaved order. Odd rounds ran 1.1.8 first, even rounds 1.2.0-beta.1 first. Both versions got faster over the session (1.1.8 from about 282 s to 232 s, 1.2.0-beta.1 from 121 s to 89 s), which interleaving spreads over both. We do not know the cause.
  • Every run verified, every run kept. All 42 restores matched the source manifest or fingerprint, so no run was dropped. Each result line carries a hash of the scripts, and the summary refuses a file with mixed hashes or anything other than 7 rounds per version and path. Three harness attempts that failed before any backup or restore ran are documented in results/discarded/.
  • A recheck with a stricter harness. Codex's review of our scripts found that a missing manifest could have counted as a match, and that the database target was not emptied before each restore. We fixed both, dropped the database before every restore, and ran two more rounds of all three paths with both versions. All 12 restores passed. The SFTP and database restores went to drill 3's replacement host, which was slower than the original app host for SFTP in both versions: 1.2.0-beta.1 took 169 and 176 s against 354 and 387 s for 1.1.8. The local restores, on the backup host, took 34 s against 56 and 58 s, and the database 8 to 11 s on both.
  • The timing is the restore command. The numbers above are the plakar restore process from start to exit. Verification and cleanup are not in them. In the drill, everything is in the clock.

Known issues in the tested versions

These are open in both 1.1.8 and 1.2.0-beta.1. None of them affected a run above, and they are not in any number:

  • plakar restore exits 0 when a file fails its integrity check; it prints a KO line and skips the file (#2576). Grep the output for KO, as the runbook does.
  • plakar check exits 0 when it cannot read a directory listing or a snapshot header, so it can miss damage (#2577). Grepping for KO is an extra signal, not proof that everything was read; check the restored data itself.
  • Each backup through a plakar server that refuses deletes leaves its lock behind (#2578). This drill does not use plakar server; the store is on the backup host's disk.

The runbook

The procedure, as a checklist, is in RUNBOOK.md, and drill/lost-host.sh runs it with a clock. The core of it, on the backup host, once the new host runs an empty Postgres and the app is stopped:

NEW_IP=10.135.0.10   # private IP of the replacement host

# point the two destinations at the new host
plakar destination rm appdb; plakar destination rm appfiles
plakar destination add appdb "postgres://forgejo@$NEW_IP:5432/" password="$PG_PASSWORD" recreate=true
plakar destination add appfiles "sftp://root@$NEW_IP/srv/forgejo/data" \
    identity=$HOME/.ssh/id_ed25519 set_owner=true

# both snapshots of the newest backup run that completed; each run tags its two
# snapshots with one label (the backup script uses -tag "$LABEL,db" and "$LABEL,files")
plakar at /srv/pk/store ls -tag "$LABEL"   # must list two: the files and the database

# restore, keep the output, and read it: exit code 0 is not proof (#2576)
plakar at /srv/pk/store restore -to @appdb <db-snapshot> 2>&1 | tee restore-db.log
plakar at /srv/pk/store restore -to @appfiles <files-snapshot> 2>&1 | tee restore-files.log
grep -c KO restore-db.log restore-files.log   # both must print 0

Then start the app, run the data checks, and only then call it recovered. Before you need any of this:

  • Keep the store passphrase somewhere that survives both hosts. Without it, the store cannot be read.
  • Put the backup host's SSH key in your app host image or cloud-init, so a new host accepts it from the first boot.
  • Back up the database first and the files second, and tag both with the same run label. If a run's files backup failed, restore the previous run as a pair.
  • Keep the compose file and image digests in Git, not only on the app host.
  • Run the drill on a schedule and write the times down. The first run is where you find the steps nobody wrote down.

If you want to rehearse the decisions around an outage before you rehearse the commands, the BCDR simulator walks through them, and the Postgres backup and recovery chapter covers pg_dump, WAL and point-in-time recovery from the database side.

What we could not conclude

  • One app, one size. 3.7 GiB and 17,499 files on 4 vCPU droplets in one region. A store ten times larger, a store in object storage, or a link between regions will give other times. The ratio between the versions may change too.
  • Three drills. They show what one recovery looks like, with its spread; they are not a distribution. The benchmark has seven runs per version and path.
  • Concurrency. On 4 vCPU, our small, sequential comparison of -concurrency 3 and 12 showed no repeatable gain. We did not test larger droplets, where more workers may matter.
  • Detection and DNS are not in our times. Our clock starts when the delete call returns and stops when the app serves, then when the data checks pass. Your real RTO also includes noticing the outage and moving traffic.
  • The data loss window is a sample. It is what three incidents at three random moments lost. For planning, if every scheduled backup succeeds, expect up to your backup interval plus the time one backup takes. A failed or late backup makes it larger.
  • Modification times. The SFTP restore set every file's modification time to the time of the restore, in both versions. Contents, modes and owners matched. Forgejo and Git do not depend on file times; check whether your app does.
  • Beta. 1.2.0-beta.1 is a beta. We will run the drill again on 1.2.0 when it ships and update this post if the numbers move.

What comes next

A faster restore shortens the RTO. The data loss window is set by how often you back up. According to the Plakar team, their next engine feature, planned for early 2027, is point-in-time recovery, which they describe as a new snapshot built from the previous one plus the changes, without a full scan of the source. If it ships as planned, it aims at the other half of this drill. We will measure it when it exists.

Summary

Losing the app server cost us about 6 minutes from the delete call to a verified app, and the writes since the last database dump. Three things decided those numbers: how fast a new host gets to an empty, running stack; how fast the backup tool puts the data back; and how often the database dump runs. Plakar 1.2.0-beta.1 shortened the second one: on the same 3.71 GiB of data, the file restore over SFTP went from 265 to 104 seconds; in 1.2, files reach the plugin in parallel and the engine has a new read path. It also kept the restore to two commands, one straight into Postgres and one over SFTP with owners, with nothing installed on the app host.

The first one is yours: an image with Docker and the app's images already in it may take a good part of the 82 to 103 seconds of bootstrap off; we did not test one. The third is a schedule: back up as often as the data loss you can accept, and remember that the files backup after the dump counts too. Then run the drill, check the data rather than the exit code, and write the times down. The scripts, the raw results and the runbook are in the demo repository.

Run the commands from this article in the browser. Nothing to install.

Published: 2026-12-14|Last updated: 2026-12-14T09:00:00Z

Tags

DevOpsBackupsDisaster RecoveryPostgreSQLPlakarForgejo

Found an issue?

Also worth your time on this topic