Syntax of tar to compress from source to target

7 respuestas [Último envío]
amenex
Desconectado/a
se unió: 01/03/2015

Here's my non-working tar/zst command where Data-B is the source folder and Data-T is the target:
cd /media/george/Data-B/george/Georgesbasement.com.B/ ;
tar -caf /media/george/Data-T/george/Data_B/Georgesbasement.com.B/35ArticlesOfImpeachment.tar.zst 35ArticlesOfImpeachment
to which tar complains: tar: /media/george/Data-T/george/Data_B/Georgesbasement.com.B/35ArticlesOfImpeachment.tar.zst/: Cannot open: Is a directory
tar: Error is not recoverable: exiting now

prospero
Desconectado/a
se unió: 05/20/2022

When in doubt, I always trust tar.

amenex
Desconectado/a
se unió: 01/03/2015

Still puzzled:
cd /media/george/Data-B/george/Georgesbasement.com.B/35ArticlesOfImpeachment
tar -caf --directory=/media/george/Data-T/george/Data_B/Georgesbasement.com.B/35ArticlesOfImpeachment.tar.zst -C 35ArticlesOfImpeachment
But tar complains;
tar: Cowardly refusing to create an empty archive
Try 'tar --help' or 'tar --usage' for more information.

Quoting from man tar:
-c, --create ==> Create a new archive. Arguments supply the names of the files to be archived.
Directories are archived recursively, unless the --no-recursion option is given.
-a, --auto-compress ==> Use archive suffix to determine the compression program.

In the present case, that's zst for zstd.
-f, --file=ARCHIVE ==> Use archive file or device ARCHIVE. If this option is not given, tar
will first examine the environment variable `TAPE'. If it is set, its value will be used as
the archive name. Otherwise, tar will assume the compiled-in default. The default value can
be inspected either using the --show-defaults option, or at the end of the tar --help output.
-C, --directory=DIR ==> Change to DIR before performing any operations. This option is order-
sensitive, i.e. it affects all options that follow.

By the way, "35AticlesOfImpeachment" contains three files; it's not empty. Of course, the target
directory, 35ArticlesOfImpeachment.tar.zst, is not empty; that compressed archive hasn't yet been
written.
Question: Tar says that the arguments must list the files to be archived. I hope that tar means
_folders_ (which contains files that have three-letter extensions) because there is no way that
I could possibly list the 2-1/2 million files that are in the partition that I'm archiving. The
command's argument specifically state that the source & target are both directories. What am I
to do about this ?

Magic Banana

I am a member!

I am a translator!

Desconectado/a
se unió: 07/24/2010

tar: Cowardly refusing to create an empty archive

Well, as tar indicates, you have not given it any file to archive. You probably simply want:
$ tar -caf /media/george/Data-T/george/Data_B/Georgesbasement.com.B/35ArticlesOfImpeachment.tar.zst /media/george/Data-B/george/Georgesbasement.com.B/35ArticlesOfImpeachment

Avron
Desconectado/a
se unió: 08/18/2020

> tar: /media/george/Data-T/george/Data_B/Georgesbasement.com.B/35ArticlesOfImpeachment.tar.zst/: Cannot open: Is a directory

The first argument should be the name of the archive file. I guess tar just tells you that there is an existing directory on your disk with that name, then tar can't create an archive file with the same name.

Magic Banana

I am a member!

I am a translator!

Desconectado/a
se unió: 07/24/2010

tar: /media/george/Data-T/george/Data_B/Georgesbasement.com.B/35ArticlesOfImpeachment.tar.zst/: Cannot open: Is a directory

Well, as tar indicates, /media/george/Data-T/george/Data_B/Georgesbasement.com.B/35ArticlesOfImpeachment.tar.zst exists and is a directory. As a consequence, tar cannot create an archive bearing the same name: there cannot be two files/directories with a same path.

amenex
Desconectado/a
se unió: 01/03/2015

Here is a tar syntax that actually works today:
cd /media/george/Data-A/george/Georgesbasement.com.A/Thumb256E/ ;
tar -caf /media/george/Data-2/george/Georgesbasement.com.A/Thumb256E/WhatsAppSpam.tar.zst WhatsAppSpam

Both target and source files already existed before I ran the commands again.

The present tar syntax doesn't work:
cd /media/george/Data-B/george/Georgesbasement.com.B/ ;
time tar -caf /media/george/Data-T/george/Data_B/Georgesbasement.com.B/35ArticlesOfImpeachment.tar.zst 35ArticlesOfImpeachment
To which tar replies:
tar (child): /media/george/Data-T/george/Data_B/Georgesbasement.com.B/35ArticlesOfImpeachment.tar.zst: Cannot open: Is a directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now

The source folder and target folder both exist, but the target folder is empty.
I've even run sudo chown -R george /media/george/Data-T/george/

Aha ! Tar -caf, etc. does not want a target directory; that directory is created by tar.
Problem with man tar interpretation solved by deleting the target directories.

Magic Banana

I am a member!

I am a translator!

Desconectado/a
se unió: 07/24/2010

Tar -caf, etc. does not want a target directory; that directory is created by tar.

Not a directory. A regular file.

Problem with man tar interpretation solved by deleting the target directories.

You need not interpret 'man tar'. You need to read and practice tar's tutorial, as I have already told you ten days ago: https://trisquel.info/forum/bootup-wont-progress-past-login-step#comment-168666

Also, if you ask a question and somebody replies, read her reply. I explained you the problem in https://trisquel.info/forum/syntax-tar-compress-source-target#comment-168821