Sample Header Ad - 728x90

Unix & Linux Stack Exchange

Q&A for users of Linux, FreeBSD and other Unix-like operating systems

Latest Questions

2 votes
2 answers
138 views
Tar cannot create symlinks on extraction
The command run to un-archive is as follows: `tar -zxvpf my_files_weekly.tar.gz --exclude=/etc/ssh/ -C / > /dev/null` Results in the following errors: tar: ./usr/share/doc/udev: Cannot create symlink to ‘libudev0’: File exists tar: ./usr/share/doc/perl-base: Cannot create symlink to ‘perl’: File exi...
The command run to un-archive is as follows: tar -zxvpf my_files_weekly.tar.gz --exclude=/etc/ssh/ -C / > /dev/null Results in the following errors: tar: ./usr/share/doc/udev: Cannot create symlink to ‘libudev0’: File exists tar: ./usr/share/doc/perl-base: Cannot create symlink to ‘perl’: File exists tar: ./usr/share/doc/vim-tiny: Cannot create symlink to ‘vim-common’: File exists tar: Exiting with failure status due to previous error However, when I specifically check these 3 mentioned directories exclusively for symlinks only like this: find -L /usr/share/doc/udev/ -xtype l -ls It reports no symlinks. I am lost. What am I missing here? For a second I thought it was perhaps the other way around and it tried to create the symlinks FROM these directories for/to "vim-common", "perl", "libudev0" and I have to find these symlinks lying around system-wide somewhere? Therefore I checked if there are any symlinks on the entire system: find -L -xtype l -ls It says there are no symlinks anywhere at all (if this command is correct though. I doubt it goes system wide). Nonetheless, my suppose that it creates symlinks FROM these directories TO the words mentioned is most probably totally wrong, but I was checking everything I could only come up with. How do I go about it and how do I extract this tar ball without it exiting due to these errors? Would **highly** appreciate any comments / suggestions / advice / assistance. Many thanks in advance! P.S. I also thought if I exclude these directories from un-packing like this it will fix the problem in one go alltogether: tar -zxvpf my_files_weekly.tar.gz --exclude=/etc/ssh/ --exclude=/usr/share/doc/perl-base/ --exclude=/usr/share/doc/vim-tiny/ --exclude=/usr/share/doc/udev/ -C / > /dev/null But... it didn't help either. The error is still there no matter what. ===== Extra Information.==== OK, I will edit it to add more information as suggested by Bodo in comments. adding -U either upper or lower case like this: tar -zxvpfu my_files_weekly.tar.gz --exclude=/etc/ssh/ -C / results in the following error: tar (child): u: Cannot open: No such file or directory tar (child): Error is not recoverable: exiting now tar: Child returned status 2 tar: Error is not recoverable: exiting now –
Dennis (125 rep)
Jul 3, 2025, 06:09 AM • Last activity: Jul 5, 2025, 10:30 AM
0 votes
0 answers
25 views
How to split tar archive on files matching pattern?
Suppose I have a large `sample.tar` with content: foo/... bar/... baz/... ... How to split in two disjoint tarballs so that one archive will contain files matching the pattern and the other archive rest? **Attempt** Looking at `--delete` in GNU tar the idea was to make 2 copies and delete correspond...
Suppose I have a large sample.tar with content: foo/... bar/... baz/... ... How to split in two disjoint tarballs so that one archive will contain files matching the pattern and the other archive rest? **Attempt** Looking at --delete in GNU tar the idea was to make 2 copies and delete corresponding parts. This side works perfectly: tar -vf sample.tar --delete --wildcards 'foo/*' 'bar/*' How to negate the selection? It seems that --delete doesn't play well with --exclude as neither of the following works (removes everything): tar -vf sample.tar --delete --wildcards '*' --exclude='foo/*' --exclude='bar/*' tar -vf sample.tar --delete --wildcards --exclude='foo/*' --exclude='bar/*' '*' **Notes** - I don't want to re-pack the archive in order to preserve all attributes (user IDs, setuid bit, timestamps etc...) - I don't want to use extra tools which are not part of standard distribution (apt install from default repository is ok, compiling from sources no) - I can imagine poor man's approach by listing the content using tar -t ... and generating arguments for negated selection but hope there is a better way - Above experiments done w/ GNU tar 1.34
user1558113 (36 rep)
Dec 2, 2024, 12:43 AM
5 votes
2 answers
1392 views
Does GNU Tar have a single option to get absolutely everything about a tree
I'm in a situation where I want the kind of guarantees of getting every bit of data and metadata about a tree of files that might normally require using dump/restore. I need *everything* uids, gids, permissions, hardlinks, attributes, xattrs, and anything else I might not even know about. And it wou...
I'm in a situation where I want the kind of guarantees of getting every bit of data and metadata about a tree of files that might normally require using dump/restore. I need *everything* uids, gids, permissions, hardlinks, attributes, xattrs, and anything else I might not even know about. And it would save me a lot of effort if I could do this for a tree instead of an image file, so dump is not the preferred path. Is there any simplified option or set of options for GNU Tar that guarantee it will catch everything? Or am I stuck with --xattrs-include='*' or --xattrs-include='*.*' and hoping I know everything?
davolfman (847 rep)
Oct 16, 2024, 06:02 PM • Last activity: Oct 17, 2024, 06:16 PM
0 votes
0 answers
99 views
Verify sha256sums of files inside tarball using hashfile
Is it possible to check the tarball's files sha256sums **without** first extracting to disk? I have this file: $ cat cathy.sha256 \SHA256 (atypical\nfilename) = ee8b2587b199594ac439b9464e14ea72429bf6998c4fbfa941c1cf89244c0b3e SHA256 (Documents/shopping list (old).txt) = 531ad778437bbec46c60ac4e3434b...
Is it possible to check the tarball's files sha256sums **without** first extracting to disk? I have this file: $ cat cathy.sha256 \SHA256 (atypical\nfilename) = ee8b2587b199594ac439b9464e14ea72429bf6998c4fbfa941c1cf89244c0b3e SHA256 (Documents/shopping list (old).txt) = 531ad778437bbec46c60ac4e3434bd1cab2834570e72cf1148db19e4c875ff50 I also have tarball (pax format) with this files inside: $ tar -tv --lzma -f cathy.tar.lzma drwxr-xr-x cathy/staff 0 2024-07-25 01:07 Documents/ -rw-r--r-- cathy/staff 758 2020-01-16 13:02 Documents/shopping list (old).txt -rw-r--r-- cathy/staff 16 2024-07-25 01:06 atypical\nfilename I tried this command but there are errors: $ tar -x --lzma -f cathy.tar.lzma --to-command='{ > printf '\''%s'\'' '\''^\\\?SHA256 ('\''; > printf '\''%s'\'' "$(sed --posix -zE '\''s/\n$//; s/\\/\\\\/g; s/\n/\\n/g; s/\r/\\r/g'\'' sed '\''s/[][\.*^$]/\\&/g'\''; > printf '\''%s'\'' '\'') = [0-9a-f]\{64\}$'\''; > } | grep -f- /path/to/cathy.sha256 | sha256sum -c -' /bin/sh: 3: Syntax error: redirection unexpected tar: 217238: Child returned status 2 /bin/sh: 3: Syntax error: redirection unexpected tar: 217239: Child returned status 2 tar: Exiting with failure status due to previous errors It must be able to handle line feeds (\n) carriage returns (\r) and backslashes (\\) in filenames, converting only those as needed to match the filenames sha256sum saves in .sha256 file (to explain the regex and printf). I expect filenames could contain all characters except NUL (\0) and forwardslash (/). ---- Putting the above --to-command code into script (undesired): $ cat tarHashHelper.sh #!/bin/bash { printf '%s' '^\\\?SHA256 ('; printf '%s' "$(sed --posix -zE 's/\n$//; s/\\/\\\\/g; s/\n/\\n/g; s/\r/\\r/g' <<< "${TAR_REALNAME}")" | sed 's/[][\.*^$]/\\&/g'; printf '%s' ') = [0-9a-f]\{64\}$'; } | grep -f- /path/to/cathy.sha256 | sha256sum -c - reads copies from disk instead (copies i had before): $ tar -x --lzma -f cathy.tar.lzma --to-command='/path/to/tarHashHelper.sh' Documents/shopping list (old).txt: OK \atypical\nfilename: OK and deleting them first gives different error: $ tar -x --lzma -f cathy.tar.lzma --to-command='/path/to/tarHashHelper.sh' sha256sum: 'Documents/shopping list (old).txt': No such file or directory Documents/shopping list (old).txt: FAILED open or read sha256sum: WARNING: 1 listed file could not be read tar: 217318: Child returned status 1 sha256sum: 'atypical'$'\n''filename': No such file or directory \atypical\nfilename: FAILED open or read sha256sum: WARNING: 1 listed file could not be read tar: 217327: Child returned status 1 tar: Exiting with failure status due to previous errors (still tries to read from disk and NOT from tarball. I want it to read from tarball)
leetbacoon (383 rep)
Jul 25, 2024, 01:48 AM • Last activity: Jul 25, 2024, 07:23 PM
0 votes
1 answers
78 views
dnf install gnutar ... bf81de15: NOKEY
I am using `dnf` configured for *OpenMandriva Cooker*, and I have this problem `bf81de15: NOKEY` when trying to install `gnutar`. What is the procedure to do in these cases? And if it is not possible, how to omit the key? ```sh Last metadata expiration check: 0:33:36 ago on Wed Apr 3 17:49:59 2024....
I am using dnf configured for *OpenMandriva Cooker*, and I have this problem bf81de15: NOKEY when trying to install gnutar. What is the procedure to do in these cases? And if it is not possible, how to omit the key?
Last metadata expiration check: 0:33:36 ago on Wed Apr  3 17:49:59 2024.
Dependencies resolved.
==================================================================================================================
 Package                  Architecture             Version                  Repository                       Size
==================================================================================================================
Installing:
 gnutar                   x86_64                   1.34-4                   cooker-x86_64                   965 k

Transaction Summary
==================================================================================================================
Install  1 Package

Total size: 965 k
Installed size: 3.1 M
Is this ok [y/N]: y
Downloading Packages:
[SKIPPED] gnutar-1.34-4-omv2390.x86_64.rpm: Already downloaded                                                   
Running transaction check
Transaction check succeeded.
Running transaction test
The downloaded packages were saved in cache until the next successful transaction.
You can remove cached packages by executing 'dnf clean packages'.
Error: Transaction test error:
  package gnutar-1.34-4.x86_64 does not verify: Header V4 RSA/SHA256 Signature, key ID bf81de15: NOKEY
ArtEze (137 rep)
Apr 3, 2024, 09:33 PM • Last activity: Apr 4, 2024, 03:28 AM
2 votes
1 answers
330 views
Is it safe to delete GNUSparseFile.0 directory?
While looking through some filesystems to see what consumes disk space I found out a directory called `GNUSparseFile.0`. I can't easily find out if its contents are used. Can it be some temporary leftover from untarring? The OS is FreeBSD so it may have been untarred with BSD `tar`.
While looking through some filesystems to see what consumes disk space I found out a directory called GNUSparseFile.0. I can't easily find out if its contents are used. Can it be some temporary leftover from untarring? The OS is FreeBSD so it may have been untarred with BSD tar.
filo (203 rep)
Apr 23, 2023, 03:45 PM • Last activity: Apr 23, 2023, 05:45 PM
1 votes
2 answers
1365 views
Extract archive with BSD tar to directory with same basename
GNU tar allows to extract the contents of an archive to a directory named after the basename of the archive. $ touch foobar $ gnutar czf archive.tar.gz foobar $ gnutar --one-top-level -xf archive.tar.gz $ ls archive/foobar archive/foobar I can get the same result with BSD tar by running multiple com...
GNU tar allows to extract the contents of an archive to a directory named after the basename of the archive. $ touch foobar $ gnutar czf archive.tar.gz foobar $ gnutar --one-top-level -xf archive.tar.gz $ ls archive/foobar archive/foobar I can get the same result with BSD tar by running multiple commands. $ destdir=$(basename archive.tar.gz .tar.gz) $ mkdir $destdir $ bsdtar -C $destdir -xf archive.tar.gz $ ls archive/foobar archive/foobar I would however like to run a _single_ command just as with GNU tar. One could of course wrap the commands into shell script or shell function but I'm wondering if there is some _builtin_ of BSD tar that produces the same result thus requiring only a single command? --- Background: I would like to use BSD tar because GNU tar currently does not seem to support extended attributes on non-Linux plattforms, at least GNU tar installed via Homebrew on macOS is currently not compiled with extended attributes support.
Stefan Schmidt (121 rep)
Nov 26, 2022, 01:34 PM • Last activity: Jan 11, 2023, 05:59 PM
0 votes
1 answers
493 views
GNU tar's "transform" option behaves inconsistently when pattern ends in "/"
I have come across the following strange behavior of GNU `tar` when using the `--transform` option to transform path elements: When I try to `tar` an entire sub-directory and want to transform the path to this directory, the transformation is _not_ applied to the directory itself, but only to its co...
I have come across the following strange behavior of GNU tar when using the --transform option to transform path elements: When I try to tar an entire sub-directory and want to transform the path to this directory, the transformation is _not_ applied to the directory itself, but only to its content, when the transformation pattern explicitly contains the /. To reproduce: * create a directory test-dir with dummy content:
$ mkdir test-dir
    $ touch test-dir/test{1..50}.txt
* tar this directory with renaming of test-dir/ to transformed-dir/, and instruct tar to print the transformed names for checking:
$ tar --transform="s,^test-dir/,transformed-dir/," --show-transformed-names -cvf test.tar test-dir
    test-dir/
    transformed-dir/test25.txt
    transformed-dir/test29.txt
    transformed-dir/test47.txt
    ...
As you can see, the directory itself is _not_ renamed correctly, although the renaming works for all files within the directory. * For comparison, use the same transformation but _without_ the trailing /:
$ tar --transform="s,^test-dir,transformed-dir," --show-transformed-names -cvf test2.tar test-dir
    transformed-dir/
    transformed-dir/test25.txt
    transformed-dir/test29.txt
    transformed-dir/test47.txt
    ...
Now, the directory itself _is_ correctly renamed. The behavior doesn't change when the ^ anchor is omitted, and is independent on whether the directory to be tarred is specified with or without trailing / on the command line. * I wondered if the problem was that when the / is specified, in case of the directory the _entire_ filename is subject to replacement. However, when specifying a transformation that would rename an entire file, that works correctly:
$ tar --transform="s,^test-dir/test29.txt,transformed-dir/file.txt," --show-transformed-names -cvf test3.tar test-dir
    test-dir/
    test-dir/test25.txt
    transformed-dir/file.txt
    test-dir/test47.txt
    ...
So it really seems that the trailing / is the problem. Is this a feature, a bug, or did I somehow misunderstand the scope/syntax of the option? The tar version is GNU tar 1.28.
AdminBee (23588 rep)
Jan 19, 2021, 09:50 AM • Last activity: Nov 2, 2022, 03:44 PM
1 votes
0 answers
203 views
GNU tar: How to mix include and exclude on when --listed-incremental is in effect?
I have a `tar` command where I need to mix "include" and "exclude" operations. This is - when not using `--listed-incremental` working perfectly, but not when combined with `--listed-incremental`: ## What I have tried: * Setup test scenario /tmp/tartest$ rm * ; touch a b * `--exclude a` *before* the...
I have a tar command where I need to mix "include" and "exclude" operations. This is - when not using --listed-incremental working perfectly, but not when combined with --listed-incremental: ## What I have tried: * Setup test scenario /tmp/tartest$ rm * ; touch a b * --exclude a *before* the include (the simple a) works as expected (a is excluded): /tmp/tartest$ gtar cvf test.tar --exclude a a b b * Include (the simple a) *before* the --exclude a works as expected (a is included): /tmp/tartest$ gtar cvf test.tar a --exclude a a b a b * --exclude a *before* the include (the simple a) works as expected (a is excluded), even with --listed-incremental is in operation: /tmp/tartest$ rm snapshot ; gtar cvf test.tar --listed-incremental=snapshot --exclude a a b b * Include (the simple a) *before* the --exclude a does *not* work as expected (a is *not* included) with --listed-incremental is in operation: /tmp/tartest$ rm snapshot ; gtar cvf test.tar --listed-incremental=snapshot a --exclude a a b b ### Where is a??? * For level-1 incremental backups, the same holds (but plays no role for this question). * My version is 1.34: /tmp/tartest$ gtar --version tar (GNU tar) 1.34 I'm skipping mentioning more tests I have done (obviously my real command line is more complex). ## Question GNU tar 1.34 is from March 2021. I cannot imagine that this very basic functionality is a long-term-bug in tar. I have browsed the bug-tar mailing list and found no relevant mention of "incremental", "include" or "exclude" whatsoever. What am I doing wrong; how do I have to fix my command line so a is included in the archive when it is present befor its respective --exclude on the command line?
AnoE (947 rep)
Sep 29, 2022, 10:53 AM • Last activity: Sep 29, 2022, 10:58 AM
2 votes
1 answers
243 views
Make tar on multiple predefined tapes
How do I `tar` some files to multiple tapes, with each tape being listed in advance? This way I can have a fully-unattended archival, with no need to physically change media once a tape is full. In my specific case, - Each tape is actually a `/dev/sd?` block device, with the archive being written to...
How do I tar some files to multiple tapes, with each tape being listed in advance? This way I can have a fully-unattended archival, with no need to physically change media once a tape is full. In my specific case, - Each tape is actually a /dev/sd? block device, with the archive being written to the raw disk and not having partitions or filesystems to save on space. - All target disks are connected to the host machine simultaneously. - tar is GNU version 1.34. - Largest single file size is smaller than the size of the smallest target. So far, to perform this task, I've got this command: tar -c -M -f /dev/tape1 -f /dev/tape2 ... /files/to/be/archived. Step-by-step walkthrough: 1. tar -c is the command to create a tar archive. 2. -M tells tar that I want to make a multi-volume archive. 3. -f is listed multiple times with each target tape to be written to. 4. /files/to/be/archived is what is to be archived. Due to --tape-length not being present in the command, tar should write as much as it can on each tape, regardless of how big the tape is in relation to others. This allows for tapes of unequal sizes. Will this work as I have explained above, or will the behavior of tar be different?
Alexander M (131 rep)
Mar 28, 2022, 10:24 PM • Last activity: Apr 13, 2022, 02:33 PM
1 votes
0 answers
33 views
Stripping and Renaming parent directory for each line output in tar -T -?
I have an list of directory output from the following command that I want to tar: `find ./temp -type f -name '*'` ``` ./temp/main/randomfile.txt ./temp/main/dir_a/random.txt ./temp/main/dir_b/random.txt ./temp/main/dir_c/random.txt ``` Then I pipe the result: `tar -zchf ./tars/randomtar.tar.gz -T -`...
I have an list of directory output from the following command that I want to tar: find ./temp -type f -name '*'
./temp/main/randomfile.txt
./temp/main/dir_a/random.txt
./temp/main/dir_b/random.txt
./temp/main/dir_c/random.txt
Then I pipe the result: tar -zchf ./tars/randomtar.tar.gz -T - Combined commands: find ./temp -type f -name '*' | tar -zchf ./tars/randomtar.tar.gz -T - This will take each result from the output and tar into randomtar.tar.gz How do I change the parent directory of each output from find command when compressing? When I untar the file, I would get:
./temp/main/randomfile.txt
./temp/main/dir_a/random.txt
./temp/main/dir_b/random.txt
./temp/main/dir_c/random.txt
I want to get this result when I untar:
./new_parent_name_main/randomfile.txt
./new_parent_name_main/dir_a/random.txt
./new_parent_name_main/dir_b/random.txt
./new_parent_name_main/dir_c/random.txt
vcoder_12 (11 rep)
Jun 25, 2021, 04:57 PM • Last activity: Jun 27, 2021, 03:16 PM
0 votes
1 answers
1158 views
Is it possible to remove the already unpacked files from .tar?
I have a `.tar` file which takes up about 70% of my disk space and I would need to unpack it to the same disk. Does the `tar` command have an option to remove the files that have already been unpacked during the process so that they don't take up the space any more? The `--delete` option seems to be...
I have a .tar file which takes up about 70% of my disk space and I would need to unpack it to the same disk. Does the tar command have an option to remove the files that have already been unpacked during the process so that they don't take up the space any more? The --delete option seems to be able to remove specific files from the .tar archive, but is there a way to tell tar to always remove the last one that has just been unpacked? This way as the unpacked files size increases, the .tar size would decrease all the way to zero in the end. Moreover, if the process is interrupted, it could be continued from where it was left since only the unpacked files would still be present in the .tar.
Botond (135 rep)
May 27, 2021, 02:02 AM • Last activity: May 29, 2021, 04:11 PM
2 votes
1 answers
2211 views
tar exclude not working as expected
I am trying to create a .tar file of the filesystem but exclude the `/proc` directory. The command I have tried is: tar -czvf mytar.tgz / --exclude='/proc' But this does not exclude the directory. I have also tried it without the single quotes. # tar --version tar (GNU tar) 1.31 How can I exclude th...
I am trying to create a .tar file of the filesystem but exclude the /proc directory. The command I have tried is: tar -czvf mytar.tgz / --exclude='/proc' But this does not exclude the directory. I have also tried it without the single quotes. # tar --version tar (GNU tar) 1.31 How can I exclude the directory?
Proletariat (707 rep)
Mar 31, 2021, 08:29 AM • Last activity: Mar 31, 2021, 09:25 AM
0 votes
1 answers
279 views
tar exclude certain directories but not in subdirectories
I need to transfer a lot of web directories to another machine. The directory structure looks like this: ``` /var/www/ site1/ cgi-bin/ ... logs/ ... index.html images/ ... ... site2/ cgi-bin/ logs/ ... size3/ ... ``` To pack the files I'd like to use `tar`. I need to pack all files, except all "cgi-...
I need to transfer a lot of web directories to another machine. The directory structure looks like this:
/var/www/
    site1/
        cgi-bin/ ...
        logs/ ...
        index.html
        images/ ...
        ...
    site2/
        cgi-bin/
        logs/
        ...
    size3/
    ...
To pack the files I'd like to use tar. I need to pack all files, except all "cgi-bin" and all "logs" directories **only** in certain provided paths, not in any subdirectory! These directories should be excluded from packing because they should not appear in the destination and they can be quite large. That slows down the transfer. So I *do not* want to include them and only delete them in the destination. I tried several combinations of this: cd /var/www tar cfz ~/web.tgz site* --exclude-from excludes.list excludes.list is a file that contains lines such as shown here: (the example shows different path styles, I used each of them consistently for the entire file, but no variant worked)
site1/cgi-bin
site1/logs
./site2/cgi-bin
/var/www/site2/logs
The "cgi-bin" directories may occur in other subdirectories (I list them all with a find command), the "logs" directories that I want to exclude are all directly in each "site*x*" directory. Other "logs" directories **must be included**. I could only get to two results: 1. No files were excluded at all 2. All directories that *partially* matched an exclude pattern were excluded, including e.g. /var/www/site2/bla/site1/logs/. This is not acceptable as it's **excluding too much**. Is there a way to make tar exclude exactly the absolute paths provided and nothing else that partially looks like a provided exclude pattern?
ygoe (263 rep)
Dec 3, 2020, 07:56 PM • Last activity: Dec 30, 2020, 11:09 PM
0 votes
3 answers
416 views
Tar exclude parameter in bash script not working
I got a tar command line that works great straight in the shell. tar --exclude=out/pictures/\*.{jpg,gif,png,jpeg} --exclude=tmp/\*.{txt,php} --exclude=log/\*.{log,sql} -cvf /backups/mydomain.tar -C /var/www/vhosts/mydomain.com/httpdocs content As soon as I put this command in a bash script and execu...
I got a tar command line that works great straight in the shell. tar --exclude=out/pictures/\*.{jpg,gif,png,jpeg} --exclude=tmp/\*.{txt,php} --exclude=log/\*.{log,sql} -cvf /backups/mydomain.tar -C /var/www/vhosts/mydomain.com/httpdocs content As soon as I put this command in a bash script and execute, it ignores the excludes parameters. I tried some various syntax like: tar --exclude="out/pictures/\*.{jpg,gif,png,jpeg}" -cvf /backups/mydomain.tar -C /var/www/vhosts/mydomain.com/httpdocs content tar --exclude='out/pictures/\*.{jpg,gif,png,jpeg}' -cvf /backups/mydomain.tar -C /var/www/vhosts/mydomain.com/httpdocs content tar --exclude out/pictures/\*.{jpg,gif,png,jpeg} -cvf /backups/mydomain.tar -C /var/www/vhosts/mydomain.com/httpdocs content tar --exclude= out/pictures/\*.{jpg,gif,png,jpeg} -cvf /backups/mydomain.tar -C /var/www/vhosts/mydomain.com/httpdocs content But nothing works. The exclude parameters are simply ignored. A simple --exclude like --exclude="tmp" works as intended. As soon I start to work with parameters it breaks cause of the syntax I assume. Im running tar (GNU tar) 1.29 on ubuntu 18.04.5.
Kuba (1 rep)
Oct 13, 2020, 03:44 PM • Last activity: Oct 14, 2020, 11:11 AM
0 votes
1 answers
413 views
Does GNU tar incremental backup save an entire file again, even if only atime or mtime is different?
``` mkdir test echo "hi" > test/file1 tar -c -f archive.0.tar -g test.snar test touch -a test/file1 # changes atime and ctime, doesn't change mtime tar -c -f archive.1.tar -g test.snar test tar -t -G -vv -f archive.1.tar # lists Y for file1 ``` So did GNU tar store the entire file again, even though...
mkdir test
echo "hi" > test/file1
tar -c -f archive.0.tar -g test.snar test
touch -a test/file1  # changes atime and ctime, doesn't change mtime
tar -c -f archive.1.tar -g test.snar test
tar -t -G -vv -f archive.1.tar  # lists Y for file1
So did GNU tar store the entire file again, even though only access time (atime) and metadata change time (ctime) were changed? This seems horribly inefficient to me, as we can reasonably expect many files to be read but not changed.
qwr (798 rep)
Jul 10, 2020, 08:31 PM • Last activity: Jul 12, 2020, 01:09 PM
0 votes
1 answers
313 views
Can GNU tar incremental backup use checksums?
According to GNU tar manual: > Incremental dumps depend crucially on time stamps, so the results are unreliable if you modify a file's time stamps during dumping (e.g., with the `--atime-preserve=replace' option), or if you set the clock backwards. The timestamps on my file is one hour off, due to d...
According to GNU tar manual: > Incremental dumps depend crucially on time stamps, so the results are unreliable if you modify a file's time stamps during dumping (e.g., with the `--atime-preserve=replace' option), or if you set the clock backwards. The timestamps on my file is one hour off, due to daylight savings time on the portable device. Is it possible to force tar to use checksums? (I'm thinking about using just about anything else because managing snapshot files seems very annoying and error-prone)
qwr (798 rep)
Jul 10, 2020, 07:34 AM • Last activity: Jul 10, 2020, 08:32 PM
5 votes
2 answers
3612 views
GNU tar not ignoring directories in gitignore with --exclude-vcs-ignores
I have a git repo: `rsh`: ``` ❯ cat rsh/.gitignore *.o shell build/ rsh_history ``` And I'm attempting to tar it up using tar (GNU tar) 1.32. The command I'm using is: ``` ❯ gtar cvaf rsh.tar.gz --exclude-vcs-ignores --exclude-vcs rsh ``` Unfortunately, the `build/` directory is included in the tarf...
I have a git repo: rsh:
❯ cat rsh/.gitignore
*.o
shell
build/
rsh_history
And I'm attempting to tar it up using tar (GNU tar) 1.32. The command I'm using is:
❯ gtar cvaf rsh.tar.gz --exclude-vcs-ignores --exclude-vcs rsh
Unfortunately, the build/ directory is included in the tarfile, in spite of build/ being specified in the .gitignore.
❯ gtar cvaf rsh.tar.gz --exclude-vcs-ignores --exclude-vcs rsh
...
rsh/build/
rsh/build/meson-private/
rsh/build/meson-private/install.dat
rsh/build/meson-private/meson.lock
rsh/build/meson-private/sanitycheckc.exe
rsh/build/meson-private/build.dat
rsh/build/meson-private/sanitycheckc.c
rsh/build/meson-private/cmd_line.txt
rsh/build/meson-private/meson_benchmark_setup.dat
rsh/build/meson-private/meson_test_setup.dat
rsh/build/meson-private/coredata.dat
rsh/build/compile_commands.json
rsh/build/rsh
rsh/build/rsh@exe/
rsh/build/.ninja_deps
rsh/build/build.ninja
rsh/build/meson-logs/
rsh/build/meson-logs/meson-log.txt
rsh/build/meson-info/
rsh/build/meson-info/intro-buildsystem_files.json
rsh/build/meson-info/intro-benchmarks.json
rsh/build/meson-info/intro-buildoptions.json
rsh/build/meson-info/intro-dependencies.json
rsh/build/meson-info/intro-installed.json
rsh/build/meson-info/meson-info.json
rsh/build/meson-info/intro-tests.json
rsh/build/meson-info/intro-projectinfo.json
rsh/build/meson-info/intro-targets.json
rsh/build/.ninja_log
...
Curiously enough, the .gitignore itself does get ignored (--exclude-vcs); as well the other files in the .gitignore (rsh_history).
xrisk (701 rep)
Aug 24, 2019, 05:48 AM • Last activity: Feb 12, 2020, 12:44 PM
2 votes
1 answers
1202 views
Unable to exclude directories while using tar
I have a folder in Home directory with the following structure: top-tree +-- .git +-- branch1 | +-- branch11 | +-- .idea | +-- branch111 | +-- branch112 | +-- branch113 | +-- branch114 | +-- branch1141 | +-- branch1142 | +-- branch1143 | +-- branch115 | +-- branch116 | +-- branch117 Now, I want to t...
I have a folder in Home directory with the following structure: top-tree +-- .git +-- branch1 | +-- branch11 | +-- .idea | +-- branch111 | +-- branch112 | +-- branch113 | +-- branch114 | +-- branch1141 | +-- branch1142 | +-- branch1143 | +-- branch115 | +-- branch116 | +-- branch117 Now, I want to tar the entire contents but must exclude all the hidden directories like .git and .idea and one particular directory branch114 which has at least 2 subdirectories (the number of subdirectories may vary from time to time). I tried to do this by using the tar command with the following parameters: tar -czvf archive.tar.gz --exclude=~/top-tree/branch1/branch11/branch114 --exclude=~/top-tree/.git --exclude=~/top-tree/branch1/branch11/.idea top-tree/ tar -czvf archive.tar.gz --exclude=~/top-tree/branch1/branch11/branch114 --exclude=~/top-tree/.* But none of the above seems to work. Every single time, the entire contents of the folder top-tree is placed in archive.tar.gz. I've tried out a lot of things (so many that I can't quote here including [this](https://unix.stackexchange.com/questions/32845/tar-exclude-doesnt-exclude-why) one) suggested in this website and others, played with the permutations of parameters etc. *But unlike other similar questions, mine seems like it's a problem with the path*. The tar version I'm using is 1.29. Why doesn't this work?
skrowten_hermit (791 rep)
Mar 21, 2019, 10:13 AM • Last activity: Mar 21, 2019, 01:35 PM
17 votes
2 answers
2743 views
Anonymous tarballs
Tar encodes my user name into the tarball. Can I force it to make a fully anonymous tarball? `--owner root` replaces only some instances of my user name. Adding `USER=root`: `USER=root tar c --owner root data` has no effect. In short, I wish for: echo hello world > data; tar c --owner root data | gr...
Tar encodes my user name into the tarball. Can I force it to make a fully anonymous tarball? --owner root replaces only some instances of my user name. Adding USER=root: USER=root tar c --owner root data has no effect. In short, I wish for: echo hello world > data; tar c --owner root data | grep "$USER" to **not** match.
Petr Skocik (29590 rep)
Apr 21, 2016, 07:10 AM • Last activity: Apr 21, 2016, 12:47 PM
Showing page 1 of 20 total questions