Tar complaining about "You must specify one of the options"

in Servers


If you're trying to create a backup using tar but you're getting this error

tar: You must specify one of the '-Acdtrux', '--delete' or '--test-label' options Try 'tar --help' or 'tar --usage' for more information.

… check your options order.

In my case, I was using --exclude. It turns out, if the paths you provide to --exclude are absolute, the --exclude flags need to go after tar options and source/destination paths.

Here's an example:

tar czf /tmp/vat.tgz /var --exclude=/var/log
#debian