Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

migrated from stackoverflow.com Mar 3 '11 at 14:29

This question came from our site for professional and enthusiast programmers.

1 Answer 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/*' ... *
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.