I’ve built a small suse 11.4 laptop that I can use to play around with new apps and not worry about blowing up my actual work laptop. Since I know that I will eventually get the o/s to a non-operational point and have to rebuild, I’d like a way to do an easy backup and restore.
I built the OS with /home in its own separate partition but everything else is under the root partition. I know I can use tar to create a tarball of the / partition and then store that tarball on my /home partition.
But here’s my question. If I had to rebuild the machine, would it be a simple as untarring the tarball back to the / partition? Would it overwrite files that were in use? Or would i need to save that tarball off to a bootable CD with a script to untar it?
When you restore your / file system with whatever means (tar, dd) you better not have that file system in use. Do so by using a live CD, rescue CD, or booting from another partition.
Also when you want to restore that / file system to the exact status as the .tar.z file contains, first remove all data from that file system. Files that come from the tarball will overwrite files with the same path/to/the/filename on the disk, but files that are not on the tarball will not be deleted.
You can not simply cut your feet under you, can’t you?
When you want to replace all and everything on a file system (or any coherent group of fiiles like a database), you should not use it at the same time. You never e=woould know what would arive first at a certain place. A running system is changing things constantly in the system group of files, think about loging, etc. Youi can use tar, but not on a moving target. You should also save with tar when things are not moving, else there will be no garantee that the result fits together.
What you want imho is a sort of system backup/restore scenario. These do exist of course, but are dependent on all sorts of wishes. A few suggestiosn:
. yours, use tar (and compress), (but preferable on a not running fs);
. about the same with rsync (to another partition, or anoither system);
. use dd, but remember that dd copies disk blocks, not knowing what is in them. On restore, the same size of partition must be available and the blocks are copied back.
. save configuration information only, when you save /etc you have got most of it, and as /etc is not that dynamic, you could save (again tar, rsync) within a running system (but do not run any configuration at the same time). Resore is rthen done by reinstall first and reloading of /etc after.
But to be honest, your tar scenario could function in practise. Try it, but I would only use it from runlevel 3 at the most, may be even better from runlevel 1. Then almost nothing is running. Log in as root on the console (in runlevel 1 that is automatic the case), mount the partition where he file is and do the tar. Of course tar will be overwrittn (when copying back), but that is not much of a problem in Linux, the running version will not be overwritten as long as it is in use.
That will usually work for an individual file, though there might be problems if the file is currently in use.
To restore everything, I would do it while booted from a live CD or similar.
To restore everything, after booting the live CD, mounting the root partition, I might “mv boot oldboot” to save the “/boot” directory. Then “rm -rf” everything except that “oldboot” that was preserved. Then restore all from the tarball. The “rm -rf boot” to remove the restored “/boot”, and finally “mv oldboot boot”. That way, I won’t have to reinstall grub. Of course, if grub was broken, then don’t try preserving “/boot”, just restore all and reinstall grub.
You could try clonezilla, a CD for backing up and restoring partitions or disks. Target can be other disks or storage somewhere else on a LAN. Naturally the system has to be not in use to this to be possible.
Thanks for all the feedback. I eventually found G4L (Ghost4Linux) and after much trial and error, I was able to use the G4L boot disk, backup up my /dev/sda1 (root) partition to an image file I placed on /dev/sda3 (home) parition. I then rebooted the machine, logged in as root, and made some destructive changes to the root partition (renamed the etc folder, stuff like that). I then booted back to the G4L boot disk, restored the image, rebooted the laptop, and everything was back to normal.