Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have two hard drives--a system drive and a data drive. The path to the data drive is /storage. Following this post, I went to the root of my filesytem and executed the following command:

tar cvpzf backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys --exclude=/storage /

Note that I excluded the data drive (--exclude=/storage) from the backup.

Now I want to restore the system drive but keep the data drive as it is. I should execute:

tar xvpfz backup.tgz -C /

From the how-to instructions, I was given the impression that the excluded folders will be disappeared after the restoration because I will need to recreate the folders I excluded. I am worried that the restoration will erase everything in the data drive because there is no /storage in the tar backup file. Is this a valid concern?

share|improve this question
    
I don't think an existing directory that was excluded by tar will be deleted upon restoring. I think the implication is that if you restore on an entirely blank, virgin system, you'll have to recreate the excluded folders. I suggest you conduct a small-scale experiment by, for instance, tarring your /etc/ directory, ignoring a few subdirectories and files, and then restore that on a temporary directory, to see how it behaves. –  roadmr Aug 19 '12 at 15:43
    
Thanks, roadmr. I tried the experiment you suggested, and result was assuring. –  Kai Aug 19 '12 at 22:29
add comment

1 Answer

up vote 1 down vote accepted

No, they will not be deleted. In general, tar extraction will erase a file or directory only if it is overwriting it with a stored one.

share|improve this answer
add comment

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.