How to stop tar from archiving the root path to files?

Solution 1:

Try option -C:

tar cvzf backup.tar.gz -C /path/to/my/files/ .

Solution 2:

I'm assuming this is in a script so try something like...

pushd /path/to/my/files
tar cfvz backup.tar.gz *
popd

Tar will only include the path specified on the command-line.