0

I'm trying to make a bare-bone backup system with the most basic tools available on openSUSE 11.3 (in this case: bash, fdisk, tar & grub legacy)

Here's the workflow for my scripts:

backup.sh:

  1. (Run from external system, e.g. LiveCD)
  2. make an fdisk script ($fscript) from fdisk -l's output [works]
  3. mount the partitions from the system's fstab [works]
  4. tar the crucial stuff in file.tgz [works]

restore.sh:

  1. (Run from external system, e.g. LiveCD)
  2. run fdisk $dest < $fscript to restore partitioning [works]
  3. format and mount partitions from system's fstab [fails]
  4. extract from file.tgz [works when mounting manually]
  5. restore grub [fails]

I have recently noticed that openSUSE (though I'm sure it has nothing to do with the distro) has different output in /etc/fstab and /boot/grub/menu.lst, more precisely the partition name is for example "/dev/disk/by-id/numbers-brandname-morenumbers-part2" instead of "/dev/sda2" -- but it basically is a simple symlink.

My questions about this:

  • what is the point of such symlinks, especially if we're restoring on a different disk?
  • is there a way to cleanly prevent the creation of those symlinks and use the "true" /dev/sdx everywhere instead?
  • if the previous is no, do you know a way to replace those symlinks on the fly in a text file? I tried this script but only works if the file starts with the symlink description (case of fstab, not menu.lst):

    ### search and replace /dev/disk/by-id/... to /dev/sdx
    while read oldVolume rest; do # get first element, ignore rest of line
        if [[ "$oldVolume" =~ ^/dev/disk/by-id/.*(-part[0-9]*$)? ]]; then
            newVolume=$(readlink $oldVolume) # replace pointer by pointee, returns "../../sdx"
            echo /dev/${newVolume##*/} $rest >> TMP # format to "/dev/sdx", write line
        else
            echo $oldVolume $rest >> TMP # nothing to do
        fi
    done < $file
    mv -f TMP $file # save changes
    

I've had trouble finding a solution to this on google so I was hoping some of the members here could help me.

Thank you.

0

1 Answer 1

1

I recommend you to use an exclude or include list to tar. Backup only necessary directories and avoid /dev /proc /mnt /media etc...

cd /
tar cvzf backup.tar.gz --exclude='dev/*' --exclude='proc/*' ... *

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .