[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-tar] Overwrite options

From: Alexander Chikovany
Subject: Re: [Help-tar] Overwrite options
Date: Tue, 8 Nov 2016 21:50:11 +0300

Yes, it is extremely what do I want - to overwrite file only if it's content or it's type is changed.
I have opened new task at savannah -
Thank you for your response again. 

2016-11-08 14:00 GMT+03:00 Pavel Raiskup <address@hidden>:
On Tuesday, November 8, 2016 1:19:36 PM CET address@hidden wrote:
> Hello, Pavel! Thank you very much for your answer. But this is not exactly what do I want.
> I want to extract one archive with backup of some files to existing directry with necessary files. If archive does not contain a file, but I have it inside existing directory, I dont want it to be removed while unpacking archive. But if archive contains new file (here I mean that everything is files - diretory, symbolic link, anything) - I want tar to overwrite it.
> For example:
> ➜  ~ mkdir -p mydir/dir-with-files
> ➜  ~ ln -s /dev/null mydir/link-will-be-dir
> ➜  ~ touch mydir/dir-with-files/file1
> ➜  ~ tar -cf mybackup.tar mydir/
> ➜  ~ rm -f mydir/link-will-be-dir
> ➜ ~  mkdir -p mydir/link-will-be-dir
> ➜  ~ touch mydir/dir-with-files/file2 mydir/link-will-be-dir/file-should-be-deleted-after-extract-since-its-parent-dir-become-symlink
> ➜  ~ tar -x --some-awesome-flag mybackup.tar
> and now i want it to have:
> mydir/dir-with/files contains file1 and file2
> mydir/dir-will-be-link is symbolic link to /dev/null

Looks like you want something like the '--recursive-unlink' option, but that
option would overwrite the non-empty directory only if (based on archive
contents) it is to be overwritten by non-directory file.  That's not
implemented, but I'm not sure I follow.


> 01.11.2016, 11:04, "Pavel Raiskup" <address@hidden>:
> On Tuesday, November 1, 2016 2:56:23 AM CET address@hidden wrote:
>  Hello.
>  I don't know if it is a bug or something like that.
>  What flag should I use if I want to overwrite existing non-empty directory by
>  symlink from my tar archive?
> There's --recursive-unlink. But I would be careful to explicitly select
> proper set of files to be extracted, rather then extract the whole archive
> (there's high chance this will cause some disaster).
> Documentation: info tar -n "Recursive Unlink"
> Pavel
>  I've tried --overwrite flag and -U, that did not
>  work. Tried with tar version 1.29 and 1.28. Here is example:
>  ➜ ln -s /dev/null test
>  ➜ tar -cf archive.tar test
>  ➜ rm -f test
>  ➜ mkdir -p test/something
>  ➜ tar --overwrite -xf archive.tar
>  tar: test: Cannot open: File exists
>  tar: Exiting with failure status due to previous errors
>  ➜ tar -U -xf archive.tar
>  tar: test: Cannot unlink: Directory not empty
>  tar: Exiting with failure status due to previous errors
>  ➜ rmdir test/something
>  ➜ tar --overwrite -xf archive.tar
>  ➜ echo $?
>  0

reply via email to

[Prev in Thread] Current Thread [Next in Thread]