I've just written over the wrong hard drive using the command:sudo sh -c 'pv /dev/sdb >/dev/sdc'How do I go about undoing this?I was creating the first even backup of the drive, and I backed up over the wrong drive...  The drive which got written over also has no backups, I was going to backup that drive next.Both drives were dm-crypt'ed.
Backed up over wrong hard drive
hard disk;data recovery;cat;dm crypt;pv
If you do not have backups, your data wasn't important.It's gone. There is no undo. Especially not with encryption involved.something that produces output > /dev/somedisk overwrites data on the device. Whatever is overwritten can not be restored, so your only chance would be if you noticed and cancelled it right away. Then probably only the first few hundred megs would be missing and you might have a chance at recovery, especially if the partitions you want to recover started somewhere further out. In this case it's a matter of restoring the partition table, from memory or using testdisk, gpart or whatever.If you did not cancel, it depends on how much output was produced, i.e. in your case whether /dev/sdb was smaller than /dev/sdc so it was only overwritten so far.However, you say it was dm-crypt'ed. That usually means LUKS. And LUKS has a header at the start. If you lose that header and the LUKS container is not still open, there is no way to get anything back. If it's still open, you want to save the output of dmsetup table --showkeys.Some people use LUKS without partitioning the drive, and then have some silly mistake in a partitioner or installer that does nothing but create a small partition table. That overwrites less than 512 bytes at the start of the disk but it's still enough to damage the LUKS header and the data is irrecoverably lost.