-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
--include option #581
Comments
Do you have pdf files directly inside Unfortunately, the behaviour of https://www.tarsnap.com/selecting-files.html So if you have
then tarsnap notices that |
Yes. It does have pdf files but nested within folder. So I guess just pass the files filtered through "find" command.
Thanks!
…On Thu, Aug 31, 2023 at 7:29 PM Graham Percival ***@***.***> wrote:
Do you have pdf files directly inside /Users/xyz?
Unfortunately, the behaviour of --include is inherited from the ancient
(1979!) tar(1) command. It's easier to think of --include as
--include-only, meaning "only include file and directories whose name
matches this".
https://www.tarsnap.com/selecting-files.html
So if you have
/usrs/xyz/my-docs/foo.pdf
then tarsnap notices that my-docs/ does not match *.pdf, so it doesn't
look inside my-docs/
—
Reply to this email directly, view it on GitHub
<#581 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAXDXUEW5G35NEUEXPE3TULXYET7TANCNFSM6AAAAAA4GZQOOA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Yes, passing filenames via |
Just for future reference, I ended up using find command as follow:
This will only include files with .docx and .pdf extension. May be there is a better and easier way to achieve this goal. |
That's one workable option! I personally would do something like this (untested):
The important thing is the (This should handle filenames with spaces, but not filenames which contain newlines. EDIT: if you have a lot of filenames, you might run out of room for the command-line arguments, which would result in missing files from your archives! For that reason, I recommend this method, instead of |
This comment was marked as outdated.
This comment was marked as outdated.
Actually, I am getting this output with my naive xargs one liner:
I am concerned about that |
Right; that'll happen if you have a lot of files. Your archive does not contain all of your pdf or docx files! Writing the list of filenames to a file would avoid that problem. |
I'm 99% confident that in the case above the archive does contain all of the files -- if there were too many to fit into a command line, xargs would run multiple tarsnap processes (of which all but the first would fail with a "archive already exists" error since all of the tarsnap processes would use the same archive name). But yes, putting the complete list of files into the command line is a bit of a weird way of doing this; much better to use the -T option. |
FWIW I would say that the safest "most unixy" way of doing this is "find ... -print0 | tarsnap -c --null -T- ...`. |
Oh right, that's a tarsnap warning, not a bash warning. So the result is if you ran
(which prints out the command-line used to generate each archive), then that archive wouldn't print the right thing. But that's another reason to go with writing to a list of files; |
I'll revisit this tomorrow morning and look at something to add to the webpage, along with reasons why other methods might not be ideal. |
Hello,
This may be very trivial but I am trying to figure out how to use include only option for tarsnap?
If I run this, I get a warning that "Archive contains no files" and it does not seem to work
tarsnap: Warning: Archive contains no files
Total size Compressed size
All archives 1.5 kB 1.4 kB
(unique data) 1.5 kB 1.4 kB
This archive 1.5 kB 1.4 kB
New data 1.5 kB 1.4 kB
However, this seems to work.
tarsnap: Removing leading '/' from member names
Total size Compressed size
All archives 8.4 MB 3.4 MB
(unique data) 8.4 MB 3.4 MB
This archive 8.4 MB 3.4 MB
New data 8.4 MB 3.4 MB
Am I missing anything? This is my tar version:
bsdtar 3.5.3 - libarchive 3.5.3 zlib/1.2.11 liblzma/5.0.5 bz2lib/1.0.8
Thanks for making Tarsnap.
The text was updated successfully, but these errors were encountered: