How do I undelete accidentally deleted records?
Asked Answered
R

8

7

I accidentally deleted a record which is a root folder, for which the program automatically cascade deletes everything. How do I undelete accidentally deleted records?

Rebutter answered 18/1, 2009 at 10:37 Comment(0)
G
6

Take a look at undark. I already used it. It it can export the rows (deleted or not) from a SQLite db file if the records were not overwritten. Last version here.

The SQLite-Deleted-Records-Parser does not give the same type of output, but can be useful.

And there are also some products like the SQLite Forensic Explorer, SQLite Repair, Sqlite Database Recovery and SQLiteDoctor.

If you are a developer you can avoid having the same problem again using litereplica. It adds single-master replication to SQLite.

But remember to enable the point-in-time recovery because as the transactions are replicated to the replicas an accidental command like DROP TABLE or DELETE FROM will also be replicated. With PITR you will be able to go to a previous point-in-time.

Or use the Backup API regularly. Although it transfers the entire db on each backup.

And remember: if you copy an SQLite file or use a regular backup approach while a transaction is active the copy can be corrupted.

Genius answered 1/7, 2017 at 20:15 Comment(3)
Just a note in case others are trying out undark or SQL-Deleted-Records-Parser, undark's last checkin was 5 years ago, and I tried to use it to recover sqlite DB (created by SQLite 3.11), but it didn't recover any entry. And I tried SQL-Deleted-Records-Parser, it didn't work neither -- no entry recovered.Attenuant
You can try this fork: github.com/mlt/undarkGenius
undark (both forks) and SQL-Deleted-Records-Parser do not work on the latest SQLite versions.Karykaryl
F
1

Unfortunately I don't know of a way, either. However, until you do a VACUUM on the SQLite database file the deleted data is generally not technically removed. Perhaps you might be able to still recover some of the data using some sort of hex editor on the file.

Fleam answered 18/1, 2009 at 14:41 Comment(0)
H
1

It might be possible to go in and see the data via a hex-editor. The only info I could find said that metadata was gone so the records weren't going to come back, but the data itself might still be there. It has a lot to do with how important the data is, I suspect it's not important enough for you to dig out a hex editor.

Honeysweet answered 23/1, 2009 at 22:54 Comment(0)
P
1

The data isn't always removed from the file straightaway. If there's lots of it and you're desperate, you could use the UNIX command strings on the file. This may help you to recover various bits and pieces of human-readable data, but it'll be a hard and inaccurate process.

Pistol answered 1/10, 2009 at 11:35 Comment(0)
M
1

I was able to recover the lost data following the instructions for Recovering Data From A Corrupt SQLite Database.

$ sqlite3 databasename.sqlite .recovery > recovered.sql

The output file contained a table called lost_and_found. I was able to work out which tables each of the rows were originally from by looking at the data. Each recovered row has four columns that relate to sqlite, and the remainder are the data. As each source table will have had different numbers of columns, the recovered data will have NULLs added.

Medin answered 28/6 at 12:34 Comment(0)
D
0

Sorry -- nope. Backups are the only option I know of.

In the future, consider never issuing DELETE queries, especially from user-accessible forms (let only the DB admin do it, if anyone) -- just include a field in your tables that marks a record as inactive and then factor that in to your queries in the WHERE clause.

Dumps answered 18/1, 2009 at 15:38 Comment(0)
N
-1

No way. Without a working backup you won't be able to restore this.

Nahtanha answered 18/1, 2009 at 12:24 Comment(0)
M
-1

If you accidentally deleted a root folder and its contents:

Check the Recycle Bin or Trash for possible recovery.
If you have a recent backup, restore the data from that backup.
Look for an "undo" feature within the application.
Contact the application's support team for assistance.
In critical cases, consider professional data recovery services.
Learn from the incident and implement safeguards to prevent future accidental deletions.
Misvalue answered 4/12, 2023 at 9:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.