# tar behaves weird



## bsus (Jul 14, 2011)

Hi,
I am using a Backup Script which should take all data in one folder together and makes this to an archive.

For this I am using: [cmd=]tar -czf /media/data /media/backup[/cmd]
The problem now is that I always am getting some weird "error" messages.
I don't now whats going wrong here


```
tar -cfv /media/backup/1.tar.gz /media/data
tar: /media/backup/1.tar.gz: Cannot stat: No such file or directory
tar: Removing leading '/' from member names
```


----------



## phoenix (Jul 14, 2011)

Tar is very picky about the order of the options.  The file name **MUST** come right after *-f*.

The command you listed will create a tarfile called v and try to add the /media/backup/1.tar.gz file and /media/data directory to it.

Try the following:
`# tar -zcvf /media/backup/1.tar.gz /media/data`
Note the addition of the *-z* to compress it, and moving the *-v* in front of *-f*.


----------



## bsus (Jul 14, 2011)

Ah, thank you 
Now it works 

I mentioned that the syntax under FreeBSD is kept very strict unlike as under GNU/Linux.
What reason does this have?

Regards


----------



## kpa (Jul 14, 2011)

GNU tar has the same strict requirements if you use the short command line options.


----------



## phoenix (Jul 14, 2011)

Read the man page.  The behaviour of tar changes depending on whether or not you use *-* in front of the options.  As in, *-zxvf* is not the same as *zxvf*.


----------

