SQL Server 2008 Mirrored DB Update Rollback - Crisis - sql-server-2008

I am a programmer who has done a very bad thing and somehow didn't select the WHERE clause before hitting F5 on an update query in SQL Server 2008.
I know this isn't a programming question but it is a question from a desprate programmer ...
Is there anyway to get the one column's data back from the transaction log or a log kept by the mirroring system?
Oh and yes, it gets better: the nightly maintenance plan for backups seems to have been turned off.
Any ideas please?
-Mike
stunned at reading "(197875 row(s) affected)"

Call off the dogs. I regenerated the database from an old backup and the source log files used to populate it.
In a more lucid moment I came to understand my question as:
Is the original value of a row stored in the transaction log of an update operation?
I'm almost sure the answer is no.
Thanks for listening.
-Mike

Mike, glad to hear you were able to recover the data. Now is the time to implement some sort of backup strategy :)
To your question, the transaction log can be backed up (every 10 minutes, etc.), but no... the original value is not persisted anywhere unless you explicitly build that functionality in. A great place to start is Ola Hallengren's great set of free maintenance scripts.

Related

Restore all Sql server transaction log but one query?

Is there any way to restore an entire Transaction Log but one query?
for example a delete query, or update query, that you accidentally execute?
Cause i know its is posible, to restore to a certain time, but what if the evil query affected only one table, and you dont want to loose the changes in the other tables?
You can certainly use ApexSQL Log. You can recover deleted or updated rows, but you can also choose what data you are going to recover.
Tool working great and it is very flexible. A lot of filters to help you narrow the search for data you want to recover.
Here you can find some info: How to recover SQL Server data from accidental UPDATE and DELETE operations.
There is no way to do that using just the tools that come with SQL Server, though as you said you can come close using point in time recovery.
I believe ApexSqlLog may allow you to do this, but I have never tested using it in that fashion. SQL Log Rescue from Red Gate also seems to allow you to do this, and whil I have used many products from Red Gate and have generally been very happy with them, I have not tried that particular product either.
This is what I would recommend you try. A fairly common scenario actually.
Restore the database to a "second" copy on the server
(full backup or log backup to bring you back to the point of loss)
Isolate the single table or data in the copy database and move it over to the live database
There are a variety of ways to accomplish step 2 such as
direct queries (insert / update)
merge statement
ssms export / import wizard
ssis etc. etc. etc.

Get all database actions (insert, update , delete, alter, ...)information

in sql server 2008 is there a way to get the user that inserted some rows, or updated, deleted, dropped, altered some tables?
can we get this information the date that occurred?
also is there a way to know if the data was inserted from the same machine or from other machine?
Edit: if it's really hard then maybe a way to achieve this is to user triggers
but is there a way to catch every action that happens on the DB so i can log them all??
something like on insert on any table
i want everything to be done on the DB so no matter what business app i use it will be logged
Unless you already had something set up in advance - a CDC mechanism of some kind it is going to be incredibly difficult to extract that information from the logs. It is possible given enough time, but it is a highly skilled forensic activity that is extremely time consuming to perform. (And relies on full logs being available.) There are third party log readers than can help with this but it will still be a huge effort.

How to recover just deleted rows in mysql?

Is it possible to restore table to last time with data if all data was deleted accidentally.
There is another solution, if you have binary logs active on your server you can use mysqlbinlog
generate a sql file with it
mysqlbinlog binary_log_file > query_log.sql
then search for your missing rows.
If you don't have it active, no other solution. Make backups next time.
Sort of. Using phpMyAdmin I just deleted one row too many. But I caught it before I proceeded and had most of the data from the delete confirmation message. I was able to rebuild the record. But the confirmation message truncated some of a text comment.
Someone more knowledgeable than I regarding phpMyAdmin may know of a setting so that you can get a more complete echo of the delete confirmation message. With a complete delete message available, if you slow down and catch your error, you can restore the whole record.
(PS This app also sends an email of the submission that creates the record. If the client has a copy, I will be able to restore the record completely)
As Mitch mentioned, backing data up is the best method.
However, it maybe possible to extract the lost data partially depending on the situation or DB server used. For most part, you are out of luck if you don't have any backup.
I'm sorry, bu it's not posible, unless you made a backup file earlier.
EDIT: Actually it is possible, but it gets very tricky and you shouldn't think about it if data wasn't really, really important. You see: when data get's deleted from a computer it still remains in the same place on the disk, only its sectors are marked as empty. So data remains intact, except if it gets overwritten by new data. There are several programs designed for this purpose and there are companies who specialize in data recovery, though they are rather expensive.
For InnoDB tables, Percona has a recovery tool which may help. It is far from fail-safe or perfect, and how fast you stopped your MySQL server after the accidental deletes has a major impact. If you're quick enough, changes are you can recover quite a bit of data, but recovering all data is nigh impossible.
Of cours, proper daily backups, binlogs, and possibly a replication slave (which won't help for accidental deletes but does help in case of hardware failure) are the way to go, but this tool could enable you to save as much data as possible when you did not have those yet.
No this is not possible. The only solution will be to have regular backups. This is very important.
Unfortunately, no. If you were running the server in default config, go get your backups (you have backups, right?) - generally, a database doesn't keep previous versions of your data, or a revision of changes: only the current state.
(Alternately, if you have deleted the data through a custom frontend, it is quite possible that the frontend doesn't actually issue a DELETE: many tables have a is_deleted field or similar, and this is simply toggled by the frontend. Note that this is a "soft delete" implemented in the frontend app - the data is not actually deleted in such cases; if you actually issued a DELETE, TRUNCATE or a similar SQL command, this is not applicable.)
If you use MyISAM tables, then you can recover any data you deleted, just
open file: mysql/data/[your_db]/[your_table].MYD
with any text editor

MySql Backup/Change Monitoring

I am new to MySQL from an admin point of view.
I have spent the last few hours googling with no luck and was wondering if anyone could point me in the right direction of either what to google for or a suggestion.
Basically I am looking for ideas on how best to monitor the data changes within a MySQL database so that I can at the end of a day look at the activity and either choose to rollback a few transactions or back to the last daily back up.
I think programatically there could be ways to do this with triggers but I am not sure if that is a good route to head down, it is just one that seemed possible to me.
roll back to a previous state. I think I will be able to do a daily dump of the database that could be rolled back to.
Cheers,
Rob
I would recommend triggers. I've used them to provide a replicated copy of a database and it works quite well. From within the trigger, insert a record into another table that indicates the operation performed and any data you need to associate with it.

How to recover the datas in MYSQL?

Can recover the data in MySql after the updation?I update the field and by mistake i lost the correct data..
No. This question has been asked multiple times already, the answer remains the same:
If you're in a transaction, you can ROLLBACK.
If you got backups or dumps, you can try to load and/or merge, and find the previous value.
Else: the value is gone.
Sorry mate, can't be done, there is no versioning in mySQL tables.
Backups, backups, and backups are, sadly, the only solution.
In case somebody comes up with an ingenious method I don't know about, at any rate 1. Stop the mySQL service and 2. if possible, stop doing anything on the machine the server runs on. But I doubt there is a solution.