Page 6 of 138 FirstFirst ... 456781656106 ... LastLast
Results 51 to 60 of 1375

Thread: Howto: Backup and restore your system!

  1. #51
    Join Date
    Apr 2005
    Beans
    63

    Re: Howto: Backup and restore your system!

    Isn't there some way to preserve the original file attributes and ownership when you extract them using tar? According the the man pages for tar the -p flag preserves permissions and --same-owner extracts files using the owner specified in the archive. Would that work?

  2. #52
    Join Date
    Mar 2005
    Beans
    36

    Re: Howto: Backup and restore your system!

    Rehevkor, what you said is true, but if knoppix does not have those users/groups in its system, it cannot create files that have those users/groups. Also, for root, the --same-owner is on by default, and you can see that we are using the -p option when we are using tar.

    Now, I think I have things working correctly, so I will repost all the steps I took:
    ---------------------------------------------------------------------------------------------------------------------------

    Backup your / partition, using tar, into 640 MB pieces. You will be prompted
    each time to put in a new "tape". If backup.tgz is still in the same place
    when you are prompted, tar will just start adding to it, so burn it
    now and delete it. Don't forget to delete any iso's that where created
    too. The following is one single command:

    tar cpvM -L $((640*1024)) --exclude=/proc --exclude=/lost+found
    --exclude=/backup.tgz --exclude=/sys --exclude=/tmp -f /backup.tgz /

    Also, when you burn the tar ball, include a copy of the following, so that you can recreate the users and groups on the knoppix system:

    /etc/group
    /etc/passwd
    /etc/gshadow
    /etc/shadow
    /etc/shadow.org


    Boot into knoppix. To become root at any time, just type su in the terminal, there is no password.

    Become root, and use cfdisk to partition your drive if necessary. You can then create the filesystems on the partitions. If you have changed the order of things, or are partitioning for the first time, reboot knoppix so it picks up the new partitions and adds them to its fstab and uses your swap partition.

    Now, we get ready to start copying our files over to the new partition. We want to retain all the owner/group info of the original files, so we copy the 5 files we kept from our original system to /etc on the knoppix system. As root,

    rm /etc/gshadow -f
    cp /path/to/five/files/<filename x 5> /etc
    chmod 766 /etc/group
    chmod 766 /etc/gshadow

    Now that you have done this, you may have trouble su'ing into root if you happen to log out. I found at this stage, the easiest thing to do is drop down into a tty, using ctrl-alt-f2. You will be root at this point. Just to make sure that we are sourcing the new passwd and group files, I "su -" again to root.

    su -
    cd

    Mount the / partition, and copy the files back. You will be prompted for the
    next CD. Make sure you aren't in the path of the CD, or you won't be
    able to unmount the CD to put in the next one -- guess how I know this

    tar xvpfM /path/to/backup.tgz -C /path/to/mounted/root/partition

    remake the /proc, /lost+found, /sys, and /tmp directories, and make sure that /tmp is writeable by all, and the sticky bit is set so that only the owner of a file in /tmp can alter it.

    chmod 777 /path/to/tmp
    chmod o+t /path/to/tmp

    edit /boot/grub/menu.lst and /etc/fstab on the new partition if necessary

    if you need to put grub on the MBR, do the following:

    grub
    root (hd0,#) where # is the / partition, numbering starting at 0
    setup (hd0) this actually installs grub on the MBR
    quit

    notes - in the /dev/hda1 notation, the first partition starts with 1
    - in the (hd0,0) notation, the first partition starts with 0
    - so, (hd0,0) is the same as /dev/hda1

    -----------------------------------------------------------------------------------------------------------------------

    Well, that should be it. I just did a system restore using this method, and things appear to be just fine. It would be nice if some others could test it out so we can iron out the bugs before we commit to this being a reliable method of saving the state of a system.
    Last edited by lakcaj; May 25th, 2005 at 04:27 AM.

  3. #53
    Join Date
    Apr 2005
    Beans
    63

    Re: Howto: Backup and restore your system!

    I'm restoring from my backup right now. I followed your steps, although I wasn't able to eject the knoppix cd to extract the backup from my DVDRW. I had to put the backup.tgz in a shared folder on my windows desktop and do this:

    Code:
    mkdir /mnt/sharedfolder
    smbmount //hostname/sharedfolder /mnt/sharedfolder
    cd /mnt/sharedfolder
    cp backup.tgz /mnt/hda2
    /mnt/hda2 being my new root on the hard drive.

    When it's finished restoring I'll update my GRUB config, remake the system folders, and see if it works. *crosses fingers*

  4. #54
    Join Date
    Apr 2005
    Beans
    63

    Re: Howto: Backup and restore your system!

    Ok, I got it to boot... sort of. During the initial startup, everything looked ok except for these two lines:

    Code:
    WARNING: .udevdb already exists on the old /dev/!
    ...
    /dev/hda2 has gone 49710 days without being checked, check forced
    The login screen eventually appeared, but when I entered my username and password I got an error window:

    Code:
    Your session only lasted less than 10 seconds. If you 
    have not logged out yourself, this could mean that 
    there is some installation problem or that you may be 
    out of diskspace. Try logging in with one of the failsafe 
    sessions to see if you can fix this problem.
    
    /etc/gdm/PreSession/Default: Registering your session with wtmp and utmp
    /etc/gdm/PreSession/Default: running: /usr/bin/X11/sessreg -a -w /var/log/wtmp -u /var/run/utmp -x "/var/lib/gdm/:0.Xservers" -h "" -l ":0" "jcestep"
    /etc/gdm/Xsession: Beginning session setup...
    mkdtemp: private socket dir: Permission denied
    Any idea what this is all about?

    Edit: Forgot to mention, when I was copying the files necessary to re-create my user in knoppix, I discovered that I had no shadow.org file. All of the others were present, but not it. Could that have something to do with this?

    Edit 2: Holy CRAP I fixed it O_o Apparently, /tmp must be world writeable, but re-creating it by hand gives it the wrong permissions. Thank you google

    I booted to the login screen and hit ctrl-alt-f1 to drop to terminal, then did this:

    Code:
    sudo chmod 777 /tmp
    I rebooted, and logged in without a problem. I wonder if this means I'm no longer a linux n00b
    Last edited by Rehevkor; May 25th, 2005 at 04:09 AM.

  5. #55
    Join Date
    Mar 2005
    Beans
    36

    Re: Howto: Backup and restore your system!

    Edit2 - make sure you set the sticky bit as well... see the text in my post above.

    Edit - I was writing this post while you were writing yours, so I missed that you were initially having problems. Congradulations on getting it to work! I'll add your discovery about /tmp to my post above. I didn't get that error because I had included /tmp in my backup, and decided later that I didn't want it, so I included excluding it in the post which I'll use as a reference for myself in the future. Without other people trying it, I would have been in the same shoes as you not so far from now


    Quote Originally Posted by Rehevkor
    ... although I wasn't able to eject the knoppix cd to extract the backup from my DVDRW.
    That's correct, you can't remove knoppix while it is running. So, you need external access to the backup, either through your network, or another CD drive, etc. I have a usb DVD drive that I used. I tried and tried to find a way to make a bootable CD that would also have my backup, and basically, just type "restore" and have everything magically happen, but I couldn't find a reliable solution. The thing I like about this method so far is that, although it might be a little time consuming, I know _exactly_ what is happening at each stage, and can recover from errors easier. I also think this method is very versatile. I could boot from a linux distro on a usb thumb drive for example, and then use the CD drive go pull in my backup. Well, enough rambling, hopefully things go well for you.

    Also, a BIG thanks to Heliode for his initial post. All I did was tie up some loose ends.
    Last edited by lakcaj; May 25th, 2005 at 04:28 AM.

  6. #56
    Join Date
    Apr 2005
    Beans
    63

    Re: Howto: Backup and restore your system!

    Thanks for that tip about the sticky bit.

    Phew. Glad that actually worked Ubuntu is now the sole OS on my laptop. Excellent thread!

  7. #57
    Join Date
    Apr 2005
    Beans
    139

    Re: Howto: Backup and restore your system!

    Heliode,

    This method rescued my system from a total messup - many thanks. One question:

    Although I *think* you concluded that it's unsafe to exclude /dev, it's still excluded in the initial howto (in the second code example, the bzip version) and the initial howto also says to mkdir /dev etc., even though I *think* it didn't get removed. Is this right, or am I muddying the waters here?
    Last edited by emendelson; June 4th, 2005 at 05:20 PM.

  8. #58
    Join Date
    Mar 2005
    Beans
    36

    Re: Howto: Backup and restore your system!

    I think the final decision was to include /dev in the tarball, and hence no need to remake the /dev directory after the restore.

    I don't really have a reason one way or the other, but including /dev worked fine for me, so unless someone has an argument to the contrary, I will continue to backup my /dev directory.

  9. #59
    Join Date
    Mar 2005
    Beans
    115

    Re: Howto: Backup and restore your system!

    Quote Originally Posted by emendelson
    Heliode,

    This method rescued my system from a total messup - many thanks. One question:

    Although I *think* you concluded that it's unsafe to exclude /dev, it's still excluded in the initial howto (in the second code example, the bzip version) and the initial howto also says to mkdir /dev etc., even though I *think* it didn't get removed. Is this right, or am I muddying the waters here?
    Hey,

    Thanks for pointing that out! Yes, I concluded it was unsafe to exclude /dev. I haven't actually tested this but a friend of mine (who generaly knows what he's talking about) warned me not to exclude /dev.

    Original howto updated.
    "Windows is something to overcome"

    Howto's by me:
    Tweak firefox! (URL now works..)
    Backup/Restore your system!
    Avoid having to reboot


    Compentux.org
    , the Linux Tip & Howto gathering initiative!

  10. #60
    Join Date
    Apr 2005
    Beans
    139

    Re: Howto: Backup and restore your system!

    Thanks to you too! One more quick question: is there any reason NOT to exclude /var/log/* ???

Page 6 of 138 FirstFirst ... 456781656106 ... LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •