tar restore went bad

Terrence Enger tenger-ew0EfhANLmVEfu+5ix1nRw at public.gmane.org
Sun Oct 26 00:42:51 UTC 2003


At 17:24 2003-10-25 -0400, aitken-BwLjziHGQLusTnJN9+BGXg at public.gmane.org wrote:
> I am trying to implement a backup plan for my network.
>
> I finally got ftp to move the .gz.tar from machine to machine. But
> when I tried to restore to see if it would work, I ran into problems
> with tar.
>
> I have read and reread man tar - it's not that long.
>
> The problem I'm having is the account that I "restored" the home
> directory for is
> pooched. I can't log into the account. I tried gong in as root and
> changing the
> password, recreating the account, recreating the group. Finally
> I created a new
> account to go in as. I know that the ns mail file is OK - I pointed my
> new account
> to it and it is working OK. But the GUI login doesn;t work.

Hmm, I don't see why this is happening.

>
> I guess I got confused when I was trying to be clever and point the
> archive to
> be created somewhere other than the home dir of the account.
>
>    tar -czvf /locbudrv/hons800bckup.gz.tar /home/chris

Actually that looks good to me.  Except that it would be more in line
with convention to end your filename with .tar.gz.

>
> Would it have been safer to just use ...
>
>    tar -czvf hons800bckup.gz.tar /home/chris
>
> from where I was (/home/chris)?...

No, you will just provoke tar into telling you that it is omitting
/home/chris/hons800bckup.gz.tar from the archive.

>
> then copy that to wherever, like /locbudrv  (which is hdb2, if that
> matters),
> and to a floppy for off-site storage, etc.?
>
> So, I'm assuming the first problem is that I got confused where I was
> when
> I created the tarball and where I was when I extracted it...

Just the latter, I am guessing.  

First of all, although you specified an absolute name for the
directory when you were creating the archive, (at least my version of)
tar removes the leading slash from names within the archive.  Thus you
get the possibility of restoring the archive at a different point
within the file hierarchy.  You have already noticed this possibility
<grin/>.

Remember that tar will list all the members (i.e., files and
directories) in the archive.  If I understand what happened, you will
see that all members have names starting `home/chris/`.

To restore things back where they came from, you want effectively to
"be in" the root directory of the filesystem when you do the restore.
You can accomplish this by `cd /`, of course, but it may be more
convenient to add option `--directory=/` to the restoring tar command.

BTW, to take care of the possibility that chris does not own
everything in /home/chris, you can execute both the save and restore
as root, using options `--same-owner --preserve-permissions` on the
restoring tar command.

>
> The second problem may be that some of the files would not overwrite
> when I did the restore - which may be part of a bigger problem: I don't
> know how to safely test the restore procedure. Ironic, because the point
> of
> all this is not to lose functionality of my  /home/chris, which is
> exactly what
> happened when I went to test the restore.

Well it would be good to keep /home/chris safe during you test.  If
you are going to test as if you are recovering from loss of that whole
directory, you can just rename it out of the way.  To test recovery
from more subtle damage, have a safe copy somewhere else.

>
> So, I ended up with chris folders within home folders, home folders
> within
> chris folders and even, at one point, a home within a home. Obviously
> I did
> sone thrashing about before I calmed down.

Well from the two tar command you gave, I would expect

    /home/
    |
    +---chris/
        |
        +---... whatever was in /home/chris before ...
        |
        +---home/
            |
            +---chris/
                |
                +---... whatever was in /home/chris before ...

I do cannot see /home/home resulting from what you described.  What
would create a home within home is if you did `cd /home` (or, starting
from /home/chris, `cd ..`) before issuing the restore command you told
us about.

Hope this helps.  Please ask again if I have misunderstood or my
writing is unclear.

Terry.
Avilable for contract programming.

>
> : /
>
> Chris


--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list