Recover overwritten filesystem
If you only overwrote the partition table, and remember the previous layout, you can just restore it. (Tip: always use sfdisk -O
to save the partition table before doing anything possibly destructive.) As long as the start is the same and the end is at least as far as the filesystem extended, it will be fine.
If you can't remember the previous layout, TestDisk can automatically find the locations of your partitions.
If you've managed to write over part of the filesystem, then it becomes a little more challenging and depends on what the filesystem was.