Skip to content
N1
CRM / Bitrix24 · Drive · data recovery

Recovering case documents: "files keep disappearing from deals"

Client: Law firm, NDA Category: CRM / Bitrix24 Stack: PHP 8, Bitrix24 D7 (Disk, CRM Factory), CLI, Bash pipeline, cron Timeline: about a week
Problem

Lawyers complained that documents were disappearing from cases. The cause turned out to be the robots of three smart processes: each named the case folder on the Shared Drive its own way and created a new one whenever the case was renamed — the old folder with the documents was left with no link from the card.

Constraints

Nothing could be deleted: these are working documents in court cases. Some links went through an external URL shortener or pointed to the old portal, some cases had their own folder containers, and ambiguous matches could only be resolved together with the lawyers.

What I did
  • Read-only discovery: the folder pool, classification of every link from the cards (working, via shortener, old portal, empty, junk), orphan folders
  • Merging duplicate folders with priority to the root case: contents move into the canonical folder, sources are not deleted, suspicious groups go to manual review
  • Syncing files from the card's file fields into the case folder without duplicates by name and size, repairing links and backfilling the service field with the folder id
  • Recreating missing folders for cases that had no working folder on the drive at all
  • A final one-command pipeline: three dry runs by default, a live run only with confirmation, stop on the first error; a nightly sync via cron
Architecture
Discovery (read-only) → Merging duplicates → Recreating folders → Syncing files and links → Nightly cron
Result

Discovery found 334 folders, 16 duplicate groups and 298 fixable shortener links. The live run processed 750 items: 2,544 files copied, 302 links repaired, 250 folder ids filled — 0 errors; a repeat check confirmed 7,182 files in place across 780 items.

What can be reused
Read-only discovery with link classification before any changes Merging duplicate folders without deleting sources A dry-run → confirmation → live run pipeline