2026/10/07

, , , ,

[Troubleshooting] Restoring a Corrupted Kopia + rclone (Teldrive) Backup Repository

🎬 Prologue: Why This Setup?

I wanted to compress and back up a few important folders, but Syncovery's setup was way too complicated. So, I went with **Kopia**—an open-source backup tool that supports deduplication, compression, and encryption. For storage, I decided to use **Teldrive** (a Telegram-based cloud) and **PikPak**, which I was already using, mounted via rclone (For more context, see my previous post, 「Free Snapshot Backup Tool for Teldrive and PikPak Users」).

[Local PC]

   ↓ Kopia (Create Snapshot)

[Kopia Repository] → Teldrive (Primary Storage)

   ↓ sync-to

[PikPak] (Secondary Storage)

My goals were clear:

- Automated daily snapshots
- Enter sleep mode automatically after maintenance
- Dual backups to both clouds if possible

⚡ Act 1: Where It All Went Wrong

One day, KopiaUI suddenly failed to connect to the repository. The error message read:

error loading index blob xn32_ea4a23af91f94e92...c1:

getContent: unable to complete GetBlob(...) despite 10 retries:

error populating output: unexpected EOF

The repository wouldn't open at all. KopiaUI kept retrying until it eventually killed the rclone process entirely.

At first, my thought process was simple:

"It's probably just one corrupted index file. I'll just delete it."

But that index file kept coming back even after deletion. Clearing the cache and reconnecting just resulted in the exact same error loop.

🔍 Act 2: The Endless Trial and Error

Attempt 1: Clearing the Cache

kopia cache clear

→ Failed. You need to open the repository to know where the cache is located, but you can't open the repository. A classic chicken-and-egg problem.

Attempt 2: Connecting with a New Cache Directory

kopia repository connect rclone --remote-path=teldrive:/KopiaBackup --cache-directory=M:\KopiaCache2

→ Failed again! The cache folder wasn't the culprit after all.

Attempt 3: Isolating the Index File

I queried the problematic files via rclone, but they didn't even exist on the remote (Teldrive). They were phantom files lingering only in the local cache.

Attempt 4: Index Recover

kopia index recover --parallel=10 --commit

→ Failed. Can't open the repository, so recovery is a no-go.

Attempt 5: Log Analysis

Digging into Kopia's detailed logs finally revealed a crucial clue.

[STORAGE] GetBlob "blobID":"xn33_b736d00b...","error":"error flushing dir cache: RC error:

Post \"https://127.0.0.1:xxxxx/vfs/forget\": error loading index blob xn32_ea4a..."

That's when it hit me. The vfs/forget RC call itself was failing. Meaning, rclone physically couldn't fetch the data from the remote storage.

🎯 Act 3: Uncovering the Root Cause

I reminded myself that Teldrive's backend is essentially a Telegram channel. Teldrive stores each file as a Telegram message. So, I decided to inspect the state of the Telegram channel directly.

Here were the results:

Channels Processed:       9

Total Files Checked:      497563

Total Parts (DB):         665312

Total Messages (TG):      665566

Missing Files:            80       ← File is gone, but remains in DB

Orphan Messages:          254      ← Message exists, but no DB reference

Cleaned Files:            80

Cleaned Orphans:          254

The cause was now crystal clear.

- 80 Missing Files: The database claimed the files were there, but the actual Telegram messages were gone.
- 254 Orphan Messages: Telegram messages were sitting there, but the database wasn't referencing them.

When Kopia tried to read one of these corrupted files as a blob, it looked for the message in Telegram. Finding no actual data, it threw the unexpected EOF error.

This wasn't a local cache issue; it was a severe data inconsistency within the remote storage itself.

✅ Act 4: The Resolution

I used Teldrive's built-in check tool to clean up the corrupted files and orphaned messages.

All channels processed successfully

Cleaned Files: 80

Cleaned Orphans: 254

Then, I reconnected the Kopia repository.

kopia repository connect rclone --remote-path=teldrive:/KopiaBackup --cache-directory=M:\KopiaCache2
Connected to repository.

Success. The repository status was perfectly normal again.

kopia repository status
Read-only:           false

Unique ID:           c8ac08b5e••••••••••••••••••••38447e0c

Encryption:          AES256-GCM-HMAC-SHA256

Content compression: true

Current Epoch:       34

💡 Act 5: Lessons Learned from This Incident

1. Take the "Experimental" Warning on rclone Backends Seriously

Kopia flashes this warning every single time you use an rclone backend:

"The rclone storage provider is not actively tested, it may cause data loss, use at your own risk"

This incident was the exact moment that warning became reality. While the rclone backend is incredibly convenient, it leaves you entirely exposed to the integrity issues of the remote storage.

2. Differentiate Between "Cache Issues" and "Remote Data Issues"

- Cache Issues: Fixed by clearing the local cache or pointing to a new directory.
- Remote Data Issues: Requires direct inspection of the remote storage backend's health.

This time it was the latter, but I wasted hours initially misdiagnosing it as the former.

3. Understand the "Hidden Layers" of Cloud Storage

To the user, Teldrive looks like a simple cloud drive. Under the hood, it's a complex beast consisting of Telegram channels + a DB index. If any inconsistency occurs between these layers, your files will appear to be lost.

4. Periodic Verification is Mandatory

# Verify Kopia snapshot integrity

kopia snapshot verify --verify-files-percent=5 --parallel=4

# Check Teldrive channel status (Recommended once a month)

Running these verifications regularly is the only way to catch problems early.

5. Wait for rclone to Flush Before Entering Sleep Mode

The root cause of this whole fiasco actually traced back to my batch script. When my PC entered sleep mode, the rclone VFS cache hadn't fully finished uploading. The PC shut down, leaving half-baked files on the remote. As this repeated over time, the file-to-message inconsistencies in Teldrive piled up.

I needed to add the following logic to my batch script:

REM Wait for rclone upload to finish before sleeping

rclone rc vfs/forget

:WAIT_RCLONE

for /f "delims=" %%A in ('rclone rc core/stats 2^>NUL ^| findstr /C:"transferring"') do set "PENDING=%%A"

echo %PENDING% | findstr /C:"name" > NUL

if not errorlevel 1 (

    timeout /T 15 /NOBREAK > NUL

    goto WAIT_RCLONE

)timeout /T 30 /NOBREAK > NUL

rundll32.exe powrprof.dll,SetSuspendState 0,1,0

📌 Summary: Checklist to Prevent Recurrence

Item Action
Sleep Mode Trigger Only enter sleep mode after rclone VFS flush is fully complete
Routine Verification Run kopia snapshot verify once a week
Remote Health Check Check Teldrive channel status once a month
Dual Backup Use sync-to to replicate data to another cloud like PikPak
Log Monitoring Periodically review Kopia and batch script logs
Backup Metadata Regularly back up kopia snapshot list --json

🎬 The Ultimate Takeaway

If I had to summarize the lesson from this incident in one sentence, it would be this:

"Behind convenience, there is always hidden complexity. And that complexity will inevitably cause a problem at least once."

The rclone + Kopia combo is undeniably powerful, but ignoring the "experimental" warning means you'll eventually pay the price. Fortunately, I didn't lose any critical data this time and got off light. But what if this had been an irreplaceable backup?

Moving forward:

1. Primary storage must be local or an officially supported backend.

2. rclone should be restricted to secondary backup duty only.

3. Make periodic verification a strict habit.

Stick to these three rules, and a disaster like this won't happen again.

📝 Epilogue

I wrestled with this issue for almost an entire day. At some point, any sane person would have thought, "Alright, I've tried enough. Let's just nuke it and create a new repository." I reached that exact breaking point. I even called in DeepSeek and the famously clever Claude to help troubleshoot, but both AIs were pretty stumped when faced with this specific edge case.

We dug through various logs, swapped out caches, attempted recovery commands, and the conversation ultimately steered toward formatting the repository entirely. But right before giving up, with a lingering feeling of "Could it really be this?", I ran this single command:

teldrive check --clean-uploads

And just like magic, the repository reconnected.

In the end, the solution wasn't found by DeepSeek, Claude, or the incredible reasoning capabilities of the latest LLMs. It was a single line of command executed by a human who just couldn't let it go until the very last moment.

I'd love to boldly declare here, "Human intuition is far superior to AI!" But the truth is, even I had absolutely no idea what would happen before I hit Enter. So, it’d be more accurate to call it an obsession rather than intuition. 😅

Perhaps the biggest lesson here has nothing to do with backup strategies, Teldrive, rclone, or Kopia at all.

No matter how smart AI gets, you still need at least one stubborn human at the end of the line who thinks, "What if I just try this?"

And thanks to that, this ordeal didn't end with a freshly wiped repository, but rather as a pretty great story about "the time a human accidentally solved a problem that AIs couldn't figure out all day."

0 comments:

댓글 쓰기

본문이나 댓글을 정독하신 후 신중히 작성해주세요