#475 Issue closed: Have BACKUP_PROG_OPTIONS --anchored by default

Labels: enhancement, fixed / solved / done

jsmeix opened issue at 2014-10-15 09:18:

When e.g. EXCLUDE_RECREATE contains something like "fs:/tmp" then
/usr/share/rear/layout/prepare/default/61_exclude_from_restore.sh
generates during "rear recover" the tar exclude patterns 'tmp' and 'tmp/' (in /tmp/rear./tmp/restore-exclude-list.txt).

Because how tar pattern matching works in particular the 'tmp' exclude pattern result that any files that contain '/tmp' in their path get excluded from restore, for example files (and directories) like /usr/tmp or /var/spool/cups/tmp and so on.

The 'tmp' above is only an example. The issue happens for all short values that become autogenerated tar exclude patterns.

Therefore - to be by default more on the safe side - I think it would make sense to have BACKUP_PROG_OPTIONS="--anchored"
in /usr/share/rear/conf/default.conf

I think if a user really wants it, he can use 'tmp' to exclude all files that have 'tmp' somewhere in their path.

The tar option --anchored is available since GNU tar version 1.13.20 according to the following tar NEWS file entry:

version 1.13.20 - Paul Eggert, 2001-08-27
...

  • New options --anchored, --ignore-case, --wildcards,
    --wildcards-match-slash, and their negations (e.g., --no-anchored).
    Along with --recursion and --no-recursion, these options control how
    exclude patterns are interpreted.
  • The default interpretation of exclude patterns is now --no-anchored
    --no-ignore-case --recursion --wildcards --wildcards-match-slash.
    This is a quiet change to the semantics of --exclude. The previous
    semantics were a failed attempt at backward compatibility but it
    became clear that the semantics were puzzling and did not satisfy
    everybody. Rather than continue to try to revive that dead horse we
    thought it better to substitute cleaner semantics, with options so
    that you can change the behavior more to your liking.

In SLE9 tar version 1.13.25 is used.

In SLE10 tar version 1.15.1 is used.

I am not at all a RHEL expert - nevertheless according to my analysis it seems:

In RHEL3 tar version 1.13.25 is used.

In RHEL4 tar version 1.14.12 is used.

In RHEL5 tar version 1.15.1 is used.

FYI:

See
http://www.gnu.org/software/tar/manual/html_section/tar_50.html
how tar pattern matching works, in particular it reads:

If anchored, a pattern must match an initial subsequence of the name's components. Otherwise, the pattern can match any subsequence. Default is '--no-anchored' for exclusion members and '--anchored' inclusion members.

Perhaps even more obviously "man 1 tar" reads:

--anchored
patterns match file name start
--no-anchored
patterns match after any '/' (default for exclusion)

gdha commented at 2014-10-15 14:44:

According the context described it seems safe to implement this, right? Any objections by anyone?

gdha commented at 2015-02-16 16:25:

added to the release notes so we can close this issue


[Export of Github issue for rear/rear.]