20

I run this from a cronjob:

tar -czvf /var/backups/svn.tgz /var/svn/*

That generates this on stderr:

tar: Removing leading `/' from member names

I would like to avoid this because it is not a real error (for me!). I want on stderr only things that I should worry about?

How can I kill that message?

I have the feeling that it is a matter of using the tar -C option but I am not sure and I don't know how.

Thanks for the help,
Dan

Dan
  • 359
  • 1
  • 4
  • 16

2 Answers2

16

your options:

-P, --absolute-names : don't strip leading `/'s from file names

or

-C /

... and a relative path for things to go into the tar, like so:

tar -C / -czvf /var/backups/svn.tgz var/svn/*
Martin Dorey
  • 103
  • 4
iiegn
  • 304
  • 2
  • 3
  • 2
    I don't want -P. I want -C but I can't get it to work. – Dan Nov 11 '10 at 15:11
  • 6
    I have found it out: tar -czvf /var/backups/svn.tgz -C / var/svn/ – Dan Nov 11 '10 at 15:13
  • Borrowing a warning regarding -P from another thread: Archives with absolute locations are a security risk. Attackers could use such archives to trick users into installing files in critical system locations. – gmode Jul 31 '19 at 14:00
  • Archives with absolute locations are a security risk. Attackers could use such archives to trick users into installing files in critical system locations. – A.B. Oct 11 '19 at 08:58
0

You can write

# ( tar czvf tar.file /path 2>&1 ) >log.file

The message will be written to log.file

HBruijn
  • 72,524
  • 21
  • 127
  • 192