I recently just overwrote one of my sql dump file by doing the following command:
mysqldump -u root -pTucson85719@ Directory > directory.sql
is it possible to get back the file that is being overwritten?
I recently just overwrote one of my sql dump file by doing the following command:
mysqldump -u root -pTucson85719@ Directory > directory.sql
is it possible to get back the file that is being overwritten?
First thing, you should enable noclobber
so this does not happen again. The option will prevent overwriting an existing file with redirection (>
). To enable it, add the option to your .bashrc
:
$ echo 'set -o noclobber' >> ~/.bashrc
Now, recovering the fille won't be simple but it is possible that you may still find it in the drive data. If you know some of the text in the file, you could unmount the drive and grep for it:
$ sudo grep 'MySQL Data' /dev/sdb2 | strings > recovered.txt
Again, you aren't guranteed to find it but I have had some luck with this method in the past. Best of luck to you!
unmount /path/to/device
. If the file is on the same partition as your OS installation, then you need to boot a live rescue CD and do the operation there.
Aug 25, 2014 at 14:02
noclobber
and proper backups to prevent having to go through the stress of a hail mary.
Aug 25, 2014 at 14:43