nuxx.net
Making, baking, and (un-)breaking things in Southeast Michigan.

bsd tar

Can any of you tell me why the following matches no files (and thusly won’t back things up?

tar -czP --include '*.sh' -f /home/telematic/backup/`date +"%Y-%m-%d_scripts.tar.gz"` /usr/local/sbin

This is with BSD tar, and there are files matching *.sh under there. In fact:

root@rowla:~telematic/backup# find /usr/local/sbin -name "*.sh"
/usr/local/sbin/fastcgi/fastcgi-katester.sh
/usr/local/sbin/fastcgi/fastcgi-c0nsumer.sh
/usr/local/sbin/fastcgi/fastcgi-rekram.sh
/usr/local/sbin/fastcgi/fastcgi-sithspawn.sh
/usr/local/sbin/fastcgi/fastcgi-nuxxfriends.sh
/usr/local/sbin/fastcgi/fastcgi-tnorman.sh
/usr/local/sbin/fastcgi/fastcgi-secure.sh
/usr/local/sbin/automysqlbackup.sh
/usr/local/sbin/webalizer_daily.sh
/usr/local/sbin/dailybackup.sh
/usr/local/sbin/lighttpd-hash.sh
root@rowla:~telematic/backup#

So, uhm… What am I doing wrong?

7 Responses

  1. zer0data October 3, 2006

    Why do you need the –include option? And what happens if you put it after your -f (filename)? How about running it with some -v(erbosity)?

    1. c0nsumer October 3, 2006

      1) Because nothing else from that dir needs to be backed up.
      2) Haven’t tried it after -f, but that shouldn’t matter.
      3) With -v it outputs nothing and finds nothing.

      1. zer0data October 3, 2006

        I’m not a BSD guy nor do I have a BSD tar sitting around. Reason the –include after -f comes to my mind, is that the manpage shows such, with an example of including pattern-match files from a pre-existing archive. I don’t know if –include is trying to act on -f or not, and personally I’d try an –include=’*’ to see if that matches anything, and then drop the include and add a -v to see if it starts packing up everything. Obviously this will isolate the use of –include as the problem.

        1. c0nsumer October 3, 2006

          Just FYI, the following works and grabs everything:
          tar -czP --include '*' -f /home/telematic/backup/`date +"%Y-%m-%d_scripts.tar.gz"` /usr/local/sbin/

          So, uhh.... WTF?

    2. c0nsumer October 3, 2006

      (2) fails, because it thinks –include is something which literally has to be glommed into the tarball.

  2. cobrabytez October 3, 2006

    Apostrophe

    Why do you need the apostrophe? Why can’t you just use *.sh

    1. c0nsumer October 3, 2006

      Re: Apostrophe

      I believe it’s because if the path is expanded to include characters which could be seen as arguments, it’ll prevent problems. Regardless, it doesn’t work right with or without.

Leave a reply