I am trying to create a tar archive with xz compression of my home directory to another non-existent directory, but it gives me error:

tar: Cowardly refusing to create an empty archive

The command I execute is:

tar cJvf /mnt/1234/a.tar.xz -C ~/

I am using debian 9.5.


You haven't told it what files you want to put in the archive.


  • Told it where to create the file
  • Told it what directory to change to

But haven't told it what to put in there.

The simplest solution might be

tar cJvf /mnt/1234/a.tar.xz -C ~/ .

Which will then put all the files into the archive with names starting with ./; e.g. ./foo ./bar ./baz

Be careful when extracting an archive like this, though, because it will extract to the current directory and may overwrite existing files, including changing permissions on the current directory.

| improve this answer | |

Your command:

tar cJvf /mnt/1234/a.tar.xz -C ~/

This does not tell GNU tar what to archive. The -C ~/ bit tells tar to cd into ~/ before doing anything, but you haven't told it what to archive.

You may have wanted to use

tar cJvf /mnt/1234/a.tar.xz -C ~/ .

This would give GNU tar the instruction to archive the current directory after changing directory to ~/.

| improve this answer | |

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.