mirror of
https://github.com/restic/restic.git
synced 2025-01-03 05:35:43 +00:00
linux default restore only user xattrs, doc update
* On Linux restore only user.* xattrs by default * restore all for other OSs * Update docs and changelog about the new restore flags --exclude-xattr and --include-xattr Signed-off-by: Tesshu Flower <tflower@redhat.com>
This commit is contained in:
parent
7dd18c66aa
commit
00212fa4a8
3 changed files with 48 additions and 1 deletions
22
changelog/unreleased/issue-5089
Normal file
22
changelog/unreleased/issue-5089
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
Enhancement: Allow including or excluding extended file attributes
|
||||||
|
during restore.
|
||||||
|
|
||||||
|
# Describe the problem in the past tense, the new behavior in the present
|
||||||
|
# tense. Mention the affected commands, backends, operating systems, etc.
|
||||||
|
# If the problem description just says that a feature was missing, then
|
||||||
|
# only explain the new behavior.
|
||||||
|
# Focus on user-facing behavior, not the implementation.
|
||||||
|
# Use "Restic now ..." instead of "We have changed ...".
|
||||||
|
#
|
||||||
|
Restic restore used to attempt to restore all extended file attributes.
|
||||||
|
Now two new command line flags are added to restore to control which
|
||||||
|
extended file attributes will be restored.
|
||||||
|
|
||||||
|
The new flags are `--exclude-xattr` and `--include-xattr`.
|
||||||
|
|
||||||
|
If the flags are not provided, restic will default to restoring
|
||||||
|
only `user` namespaced extended file attributes on Linux, and all
|
||||||
|
extended file attributes on other operating systems.
|
||||||
|
|
||||||
|
https://github.com/restic/restic/issues/5089
|
||||||
|
https://github.com/restic/restic/pull/5129
|
|
@ -3,6 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/restic/restic/internal/debug"
|
"github.com/restic/restic/internal/debug"
|
||||||
|
@ -300,6 +301,14 @@ func getXattrSelectFilter(opts RestoreOptions) (func(xattrName string) bool, err
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// no includes or excludes, set default of including all xattrs
|
// User has not specified any xattr includes or excludes
|
||||||
|
if runtime.GOOS == "linux" {
|
||||||
|
// For Linux, set default of including only user.* xattrs
|
||||||
|
return func(xattrName string) bool {
|
||||||
|
shouldInclude, _ := filter.IncludeByPattern([]string{"user.*"}, Warnf)(xattrName)
|
||||||
|
return shouldInclude
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
// Not linux, default to including all xattrs
|
||||||
return func(_ string) bool { return true }, nil
|
return func(_ string) bool { return true }, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,6 +88,22 @@ disk space. Note that the exact location of the holes can differ from those in
|
||||||
the original file, as their location is determined while restoring and is not
|
the original file, as their location is determined while restoring and is not
|
||||||
stored explicitly.
|
stored explicitly.
|
||||||
|
|
||||||
|
Restoring extended file attributes
|
||||||
|
----------------------------------
|
||||||
|
|
||||||
|
By default, user namespaced extended attributes for files are restored on Linux,
|
||||||
|
and all extended attributes are restored for other operating systems.
|
||||||
|
|
||||||
|
Use ``--exclude-xattr`` and ``--include-xattr`` to control which extended
|
||||||
|
attributes are restored for files in the snapshot. For example, to restore
|
||||||
|
user and security namespaced extended attributes for files:
|
||||||
|
|
||||||
|
.. code-block:: console
|
||||||
|
|
||||||
|
$ restic -r /srv/restic-repo restore 79766175 --target /tmp/restore-work --include-xattr user.* --include-xattr security.*
|
||||||
|
enter password for repository:
|
||||||
|
restoring <Snapshot of [/home/user/work] at 2015-05-08 21:40:19.884408621 +0200 CEST> to /tmp/restore-work
|
||||||
|
|
||||||
Restoring in-place
|
Restoring in-place
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue