The answer to it is both simple and complicated.
There was a program called Remastersys, with which one can backup the existing OS(Debian/Ubuntu) with all settings and files to a live CD/DVD with which one can Live boot to the OS with all files and settings, or install the OS with all files and settings. Development was ceased sometime around 2013 :(
A fork of that original project is Respin
Deb package and source is available here
You can use it to do the same. I have not tested it yet though, but should work.
BACKING UP EVERYTHING
As for backing up the entire system along with Windows + Ubuntu + MBR + Bootloader there are many ways to do it. I am going to describe one of the method that should work:
- Take a External HDD with size greater that your existing HDD
- Create a Live Ubuntu Pen Drive and boot using the Live Pen Drive
- Connect the External HDD where you will be taking the backup.
- Open a terminal and backup your Existing HDD to a Image file in your External HDD by using dd in the following way
CAUTION: Understand what you are doing. 'dd' can overwrite anything, including your existing HDD as well. Research carefully how to identify you hard disk drives, or you may end up destroying everything.
sudo dd if=/dev/sdx of=/media/ubuntu/HDD/diskimage.img bs=64K
Here /dev/sdx should be /dev/sda or /dev/sdb or whatever your existing hard disk is. Make sure it is not a partition like /dev/sda1 or something.
Make sure none of the partitions of the Existing HDD is mounted.
The external HDD when connected should be found under /media/ubuntu like if you have named your external hard disk as HDD, it will show as /media/ubuntu/HDD/
/media/ubuntu/HDD/diskimage.img is the backup image file you are creating to backup the HDD.
The process is going to take a very long long time, depending upon the size of your existing hard disk. After you have entered the above mentioned command, there will be no output or progress. It might seem that nothing is happening. Status will be shown only after the process has completed. So don't worry, just let it run. If you want to verify whether something is actually happening, just open another terminal and type:
rerun this df -TH again after some time, you will notice Available and Used size of your External Hard Disk will change with time.
After the process is complete, final status will be shown. and you are done.
You can repeat this process as frequently as you think necessary.
To restore you system after crash or corruption just follow Steps: 1-3
In Step:4, interchange the if and of path like this:
sudo dd if=/media/ubuntu/HDD/diskimage.img of=/dev/sdx bs=64K
and let the process complete. After the process has completed, just shutdown, remove Bottable Pen Drive and External HDD and just boot normally. You should get back to the state in which you had taken the last backup.
In my opinion, instead of painstakingly backing up HDD like this, you should rather keep backup of all your data in separate partition and back them up regularly to External HDDs using tools like rsync
At the most, you can backup your Ubuntu installation using programs like Respin, for rest of the part, you should consider re-installation.