Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages

Help for owners

My database has wrong, duplicated or missing data

Short answer

Wrong or missing data usually comes from a faulty update, a migration, a bug that saves bad values or two processes writing at once. The first rule is to stop the damage and keep what exists. Do not fix records by hand or restore an old copy over the live data. Ask for a backup copy first.

  • Written for business owners
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Does this sound like your situation?

  • Customers or orders appear twice, or totals do not add up.
  • Records disappeared after an update or a move to a new server.
  • Names, dates or amounts show strange characters or wrong values.
  • Two staff members see different numbers for the same thing.
  • The problem began on a certain day and keeps growing.

Why does this happen?

  1. A migration or update changed data wrongly

    Moving data between systems or changing its structure can cut text, change date formats, drop columns or leave out rows if a step was not checked.

  2. A bug keeps writing bad values

    If the app saves wrong data, every new record adds to the damage. Fixing old records without fixing the bug just repeats it.

  3. Two things changed the same record at once

    Without proper safeguards, two users, two servers or a retry can write the same thing twice or overwrite each other.

  4. Character encoding went wrong

    Mixing text encodings between app, database and import files turns letters into question marks or symbols, mostly in names and non-English text.

  5. No recent backup to compare with

    PostgreSQL's documentation describes restoring a database to its state at any time since a base backup, but only if the backup and the continuous log files were being kept. Without them there is nothing to go back to.

What can I do about it today?

  1. Stop what is making it worse if you can do it safelyIf one process is clearly adding bad data, such as a bulk import or a sync, ask your developer to pause it. Do not switch off the database or server.
  2. Do not fix records by handManual edits change the evidence and can hide the pattern. Write down examples instead: what it says, what it should say, and where you saw it.
  3. Ask for a backup copy nowAsk your developer or host to take and keep a copy of the database as it is today, and to list which backups exist and from what dates.
  4. Do not restore an old backup over the live dataThat erases everything entered since the backup. Restoring is a decision to make after the damage is understood.
  5. Write down when it startedThe date of the last update, migration or change is the most useful clue.

When should I bring someone in?

  • Money, orders or customer records are affected.
  • The bad data is still spreading.
  • There is no backup, or no one can say where the backups are.

How do I handle it?

  1. Preserve firstI take a copy of the current state before anything else, so every later step can be undone.
  2. Measure the damageI query the data to show how many records are wrong, since when, and what they have in common.
  3. Find and stop the causeI trace the pattern to an update, a bug or a process, and fix it before touching old records.
  4. Repair in a copy, then in productionI write the repair, run it on a copy, compare the result with your examples, then apply it with a tested rollback.
  5. Set up safeguardsRegular tested backups, checks that reject bad values and a short report on data counts.

The price depends on what I find, so I quote in writing after a short discovery call. Tell me what is happening and I reply within 24 hours.

What do owners ask about this?

Can the original data be recovered?

It depends on what backups exist and how the damage happened. I tell you what is recoverable before any change.

Should I tell my customers?

If their data or money is involved, yes, and soon. I help work out what is affected so the message is accurate.

Could someone have hacked it?

Possible but less common than a bug or a bad migration. If the pattern looks like tampering, see the hacked website page.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Found a mistake? Tell me.

For your developer: the technical fixes

Next step

Want this off your desk?

Send me a few lines on where things stand. I reply within 24 hours.