hydrus/db/help my db is broke.txt

93 lines
4.7 KiB
Plaintext

If you are getting weird but serious-sounding errors like 'database image is malformed', your database may be corrupt!
Ninety-nine times out of a hundred, corrupted databases happen because of hardware failure, usually the hard drive writing bad sectors due to a power cut or old age. This is a serious problem.
first, shut everything down
Close the client immediately.
If you are on Windows, open task manager (Ctrl+Shift+Esc) and wait for client.exe to disappear from the list. If it takes more than a couple of minutes, forcibly close it with task manager.
check integrity
Then check your hard drive's integrity.
On Windows, go Start->Run (Win+R) and type 'cmd'. Type chkdsk into the new window and wait for it to scan your drive.
If it finds many problems, then your drive has been compromised in some way and you should view it as unreliable. If it is an old drive, you should think about buying a replacement. The exception to 'buy a new drive' is if the existing one is new, otherwise works well, and you can trace the error to a specific event, such as an unprotected power surge during a storm that violently reset your computer. The other exception is if you cannot afford it. :/
On Windows, tell chkdsk to fix the problems it found by running it again with the /F modifier, like 'chkdsk /F'.
Another good tool is CrystalDiskInfo, which checks hard drive health at the physical level. If your drive is having trouble reading or seeking or it is piling up uncorrectable sectors, it is time to move everything off!
If your hard drive is fine, please send me the details! If it could be my code breaking things, I want to know asap!
now what?
If you have a recent backup of your client, it is probably a good idea just to restore from that. A lot of hard drive errors cannot be recovered from, so if your backup is good, this may be the only way to recover the lost information. Make a copy of your corrupted database somewhere (just in case of other problems or it turns out the backup is also corrupt) and then restore your backup.
If you do not have a backup, you'll have to try recovering what data you can from the corrupted db.
First of all, make a _new_ backup of the corrupted db, just in case something goes wrong with the recovery and we need to try again. You can just copy the client*.db files, but having a copy of all your media files is a great idea if you have the time and space. Please check the help for more information on making backups--they are important!
fix the problem
One way to fix common small problems is to instruct the database to copy itself completely. When it comes across damaged data, it will attempt to cleanly correct or nullify the broken links. The new copy often works better than the original.
So: open the SQLite shell, which should be in the db directory, called sqlite3 or sqlite3.exe. Type:
.open client.db
PRAGMA integrity_check;
And when you are ready to close the shell cleanly, go:
.exit
The integrity check doesn't correct anything, but it lets you know the magnitude of the problem: if only a couple of issues are found, you may be in luck. There are several .db files in the database, and client.db may not be the one broken. If you do not know which file is already broken, try opening the other files in new shells to figure out the extent of the damage. This is the same as with client.db, like so:
(Do this in fresh new shells of sqlite3)
.open client.caches.db
PRAGMA integrity_check;
.exit
.open client.master.db
PRAGMA integrity_check;
.exit
.open client.mappings.db
PRAGMA integrity_check;
.exit
client.mappings.db is usually the largest and busiest file in most people's databases, so it is a common victim.
If the errors do not look too bad, then try cloning a fresh copy of the broken db file like so:
.open client.db
.clone client_new.db
And wait a bit. It'll report its progress as it tries to copy your db's info to a new, cleaner db. Remember to go '.exit' once it is done to close the shell neatly.
If the clone operation is successful, rename client.db to client_old.db and client_new.db to client.db. If the damage is in a different file, do a similar operation:
.open client.caches.db
.clone client.caches_new.db
.exit
.open client.master.db
.clone client.master_new.db
.exit
.open client.mappings.db
.clone client.mappings_new.db
.exit
Do not delete your original files for now. Just rename them to 'old' and move them somewhere safe. Make sure your new cloned files are all named right and then try running the client!
If the clone is unsuccessful or it still does not run correctly, contact me (Hydrus Dev) and I'll help you with the next steps. In the worst case, we will manually extract what you can to a new db.
If you recover ok but still get problems, please contact me. Check install_dir/help/contact.html for ways to do this.