-   Linux - General (
-   -   need help backing up entire linux system the hard way... (

bl0tt0 02-21-2006 06:26 PM

need help backing up entire linux system the hard way...
Ok, I'm still in the process of learning linux, and right now I'm interested in backing up my entire system to a DVD since I've gotten things pretty well configured. I know everything will fit on one DVD, since everything together only takes up 3.9 GB of space.

On my initial install for a dual boot system, I put all of the partitions for linux on its own extended partition for this very reason. My thinking was that I could simply copy all of the data from the extended partition using dd and piping the output from that into mkisofs, and then burn the image made from that to a DVD. Now that I am looking into actually doing it however, it doesn't seem like there is much information on how to actually do this, or if it is even possible.

I've looked around the forums and google for an answer to what I specifically want to do, but most of the time the solutions involve using more user friendly system backup programs available for linux. I am interested in learning how to do this kind of thing with the bare essentials though, since there is no telling when it will be useful to know exactly how to do this later on. Does anybody know whether my idea is workable, or whether there is another solution out there I can use to get my entire system on one DVD where I can use just the basic *NIX tools included with any distrobution to recover lost data?


ilikejam 02-21-2006 07:09 PM


The usual way to archive Unix filesystems is to use tar.

cd /
tar cvf archive.tar *

will create a tar file called archive.tar in the / directory which contains everything on the system. Then burn the tar file to a DVD (using mkisofs and cdrecord).
Or you can compress the tar file as it is created.

cd /
tar czvf rachive.tar.gz *

and again burn to disk.


bl0tt0 02-21-2006 09:27 PM

Ok, thanks for the quick reply. Your suggestion is definitely closer to what I want to do, but I still have some questions about it. I assume that running mkisofs on the tar file will make an iso containing the tar file, right? I would like to be able to keep the data contained on each partition separate, so that it would be possible to access and restore each portion of the system without having to untar the entire contents of the dvd at once. Does that mean that I should try to tar each partition separately and then run mkisofs on each individual file in order to create a multi-session disc that contains everything? Also, how would I go about doing that?

Also, would I need to output the tar file to an external hard drive in order to avoid being caught in a loop in with the tar file keeps adding itself to the archiving process? Is there a way to pipe everything through the next step in order to move everything directly to the dvd? I have read in the man page that mkisofs can take a tar archive and pipe it directly into cdrecord, so it would seem like the issue would be piping the output of tar directly into mkisofs. I know that this would make things much more complicated, and I'm only asking because I'm interested in knowing if it can be done.

Thank you for the help thus far

haertig 02-21-2006 10:07 PM

Here is an example, but I'm not sure if this is what you're after:

For something small that you know will fit on a CD, you can do something like this example. The first line erases a CD-RW, the second burns a copy of /etc to the CD (in this example my cdrom drive is /dev/hdc, yours may be different).

# cdrecord -v -blank=fast -dev=/dev/hdc
# mkisofs -r /etc | cdrecord -v -dev=/dev/hdc -fs=8m -data -

You may or may not want the -r option to mkisofs.

Then to access the data on the CD:

# mkdir /mnt/tmp
# mount -t iso9660 -o loop /dev/hdc /mnt/tmp
# cd /mnt/tmp
# ls

This can be extended to DVD size images by using growisofs (part of the dvd+rw-tools package) instead of mkisofs/cdecord.

bl0tt0 02-22-2006 09:12 AM

Thanks haertig, your suggestion is almost exactly what I want to do. I looked into growisofs, and it seems to be just what I was looking for in a program. I invoked the -dry-run flag on my system just to see whether I was getting everytihng run through it, and it seems like there were a couple of problems.

The command I ran was:

growisofs -dry-run -Z /dev/hdc -speed=1 /
It took a few minutes to get through everything, but as I was observing the text going by, it would say something along the lines that it was ignoring the symlinks, and also that many of the directories went too deep for it (something like the maximum depth it could go to was 6. Would the workaround for this involve burning a multi-session disk where I start from the deeper parts of the filesystem and work my way out? Then again, perhaps this is the case for first using tar to archive each partition and then burning them to a multi-session disk. I've learned about how to move a filesystem partition from one harddrive to another through a livecd by mounting the the source and target partitions and then using a tar command and pipe along that goes something like this:

# cd /mnt/src/hda1; tar -cf - . | (cd /mnt/dst/hdb1; tar -xpf -)
I got that command through earlier help on the boards, though I have to say I still don't quite understand everything in it. I'm wondering if there would be a way to add in either one more step to extract the archive onto the burned disk (I'm thinking that this probably won't work due to the issues with symlinking and directory depth), or changing the pipe destination command so that it burns the tar archive directly to DVD. The latter seems like the cleanest option to me since I would have each partition separated out into its own individual tar file, and I would be able to copy them back through mounting the disk as you showed and then untarring to the mounted recovery partition. Am I right?

Thank you for the help

haertig 02-22-2006 11:56 AM


Originally Posted by bl0tt0
... as I was observing the text going by, it would say something along the lines that it was ignoring the symlinks, and also that many of the directories went too deep for it...

I have only used growisofs to burn DVD's of limited areas, like my photo collection directory. Tons of large JPGs, but no symlinks nor deep directory structures. I haven't run into your issue before. I haven't used growisofs all that much either. Most of my backups are sent across the LAN to other computers, and occasionally burned to CD's or DVD's from there. So I have an intermediate file to work with. I have had varied luck burning DVD's and having them readable on other readers than the one that created them. This may be due to some of my aging hardware. It sounds like you'd really like to do this on a single machine without creating any intermediate files. I haven't quite come up with a solution to that, given the problems you're reporting with growisofs. I expected growisofs to work for you.

One thing to be concerned with, no matter how you end up accomplishing this in the end, is backing up a filesystem that is "live" (thus possibly being changed AS you are backing it up). You've already mentioned this concern so it sounds like you're on top of the concept. The safest way is to boot from a Knoppix CD and work with your partitions mounted readonly. But this only works for manual backups. And when you're willing to take the system down for backups. But it sounds like something you might want to do for your initial backup of your brand-spanking-new Linux system. Personally, I used Knoppix to run dd's of my /boot and / (root) partitions. Both of these are small (I have /usr, /var, /home, etc. all on seperate partitions - LVM volumes to be more accurate). Since /boot and / rarely change I do not back them up often. For all other filesystems I create an LVM snapshot and use rsync to create backups from the snapshot. Sometimes tar if I want a complete backup. rsync across the LAN mostly though. You could also try using unionfs to create a snapshot for backing up if you don't use LVM and like the idea of snapshots. But rsync generally does the right thing if files are changing out from under it, and snapshots may not really be required. Possibly, if you have a large and busy database for example.

If you have a LAN with another computer available you can backup to there. If the other computer is Linux you can explore things like dd if=/dev/hda | gzip | ssh user@remote 'dd of=hda.gz'. I would boot Knoppix to do this. If it's a Windows computer you will be remotely backing up to, again, boot Knoppix, mount a Windows share something like mkdir /mnt/tmp; mount -t smbfs -o rw,umask=0000 // /mnt/tmp and then run something like dd if=/dev/hda of=/mnt/tmp/hda.bin

I realize that none of the above actually answers your current question about growisofs and the depth/symlink thing. Maybe someone else better versed in growisofs in a scenerio similar to yours will jump in and suggest something.

p.s. - I would also recommend staying away from multi-session DVD's or CD's. Just because. It can be bad enough getting all this to work anyway, and I wouldn't want to throw that complication into the mix.

bl0tt0 02-27-2006 10:56 AM

Well, thanks to a rebate deal at tigerdirect, I decided to bite the bullet and buy an additional 250GB harddrive for around $70, and use that one solely for backups, rescue, and forensics. The tar command works like a charm, and I was also able to burn the tarballs of my partitions to a DVD without any issues. Thanks for all of the help in that regard.

However, I'm still interested in finding a way to do a backup to CDR/DVDR without the extra step of putting the files on to a hard drive or using anything beyond simple unix commands. Sometimes the media and tools just aren't available, and I would like to learn how to work through a problem like that.

Thank you

Boow 02-27-2006 01:46 PM

goggle partimage. it works sort of like ghost. if you have a knoppix cd it already has partimage. this would be better because you dont want to run partimage while the system is running. do it saftly from knoppix cd.

All times are GMT -5. The time now is 06:09 PM.