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?

  • 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

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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