tar - How to exclude a directory?

Ralf Mardorf silver.bullet at zoho.com
Wed Mar 22 12:22:10 UTC 2017


Hi,

this is from a backup script:

cd /media/winos7
stopwatch_start
tar --exclude=./winOS_2/ardour_ragrug-2017-mar-21-DONT_DEL_AT_IO_ERROR/cubasis \
  $ATT -czf $BACKUP_DIR_Q/arcwinos7_$BACKUP_NAME_ADD$ARCH_BACKUP_NAME_EXTENSION.bak.tar.gz *

It should exclude the
directory /media/winos7/winOS_2/ardour_ragrug-2017-mar-21-DONT_DEL_AT_IO_ERROR/cubasis
but it doesn't. I also tried with ''. The "\" is part of the original
script, IOW the command is split to two lines.

$ATT is an empty string, but could also contain "--xattrs". The other
variables $BACKUP_DIR_Q, $BACKUP_NAME_ADD and
$ARCH_BACKUP_NAME_EXTENSION are valid file strings for the file name.
"DONT_DEL_AT_IO_ERROR" is not a variable, I haven't forgotten the "$".
"stopwatch_start" just starts a stopwatch that has got no impact on tar.

How could I use tar's "--exclude" option to exclude the
directory /media/winos7/winOS_2/ardour_ragrug-2017-mar-21-DONT_DEL_AT_IO_ERROR/cubasis ?

Regards,
Ralf





More information about the ubuntu-users mailing list