mirror of
https://github.com/octoleo/restic.git
synced 2024-11-28 15:56:37 +00:00
Merge pull request #3677 from restic/3490-polish
check: Adjust help and documentation for check --read-data-subset
This commit is contained in:
commit
6aefe3e111
@ -1,9 +1,8 @@
|
|||||||
Enhancement: Support for specifying file size in `check --read-data-subset`
|
Enhancement: Support random subset by size in `check --read-data-subset`
|
||||||
|
|
||||||
To check a subset of repository files, the `check --read-data-subset` command
|
The `--read-data-subset` option of the `check` command now supports a third way
|
||||||
used to support two ways to select a subset - A specific range of pack files,
|
of specifying the subset to check, namely `nS` where `n` is a size in bytes with
|
||||||
or random percentage of pack files. We have added a third method to select pack
|
suffix `S` as k/K, m/M, g/G or t/T.
|
||||||
files - By specifying file size. This new option is available with the 'restic check' command.
|
|
||||||
|
|
||||||
https://github.com/restic/restic/issues/3490
|
https://github.com/restic/restic/issues/3490
|
||||||
https://github.com/restic/restic/pull/3548
|
https://github.com/restic/restic/pull/3548
|
||||||
|
@ -56,7 +56,7 @@ func init() {
|
|||||||
|
|
||||||
f := cmdCheck.Flags()
|
f := cmdCheck.Flags()
|
||||||
f.BoolVar(&checkOptions.ReadData, "read-data", false, "read all data blobs")
|
f.BoolVar(&checkOptions.ReadData, "read-data", false, "read all data blobs")
|
||||||
f.StringVar(&checkOptions.ReadDataSubset, "read-data-subset", "", "read a `subset` of data packs, specified as 'n/t' for specific subset or either 'x%' or 'x.y%' for random subset")
|
f.StringVar(&checkOptions.ReadDataSubset, "read-data-subset", "", "read a `subset` of data packs, specified as 'n/t' for specific part, or either 'x%' or 'x.y%' or a size in bytes with suffixes k/K, m/M, g/G, t/T for a random subset")
|
||||||
f.BoolVar(&checkOptions.CheckUnused, "check-unused", false, "find unused blobs")
|
f.BoolVar(&checkOptions.CheckUnused, "check-unused", false, "find unused blobs")
|
||||||
f.BoolVar(&checkOptions.WithCache, "with-cache", false, "use the cache")
|
f.BoolVar(&checkOptions.WithCache, "with-cache", false, "use the cache")
|
||||||
}
|
}
|
||||||
@ -67,7 +67,7 @@ func checkFlags(opts CheckOptions) error {
|
|||||||
}
|
}
|
||||||
if opts.ReadDataSubset != "" {
|
if opts.ReadDataSubset != "" {
|
||||||
dataSubset, err := stringToIntSlice(opts.ReadDataSubset)
|
dataSubset, err := stringToIntSlice(opts.ReadDataSubset)
|
||||||
argumentError := errors.Fatal("check flag --read-data-subset must have two positive integer values or a percentage or a file size, e.g. --read-data-subset=1/2 or --read-data-subset=2.5%% or --read-data-subset=10G")
|
argumentError := errors.Fatal("check flag --read-data-subset has invalid value, please see documentation")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if len(dataSubset) != 2 {
|
if len(dataSubset) != 2 {
|
||||||
return argumentError
|
return argumentError
|
||||||
@ -86,7 +86,7 @@ func checkFlags(opts CheckOptions) error {
|
|||||||
|
|
||||||
if percentage <= 0.0 || percentage > 100.0 {
|
if percentage <= 0.0 || percentage > 100.0 {
|
||||||
return errors.Fatal(
|
return errors.Fatal(
|
||||||
"check flag --read-data-subset=n% n must be above 0.0% and at most 100.0%")
|
"check flag --read-data-subset=x% x must be above 0.0% and at most 100.0%")
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -96,7 +96,7 @@ func checkFlags(opts CheckOptions) error {
|
|||||||
}
|
}
|
||||||
if fileSize <= 0.0 {
|
if fileSize <= 0.0 {
|
||||||
return errors.Fatal(
|
return errors.Fatal(
|
||||||
"check flag --read-data-subset=n n must be above 0.0")
|
"check flag --read-data-subset=n n must be above 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -248,12 +248,12 @@ integrity of the pack files in the repository, use the ``--read-data`` flag:
|
|||||||
repository, beware that it might incur higher bandwidth costs than usual
|
repository, beware that it might incur higher bandwidth costs than usual
|
||||||
and also that it takes more time than the default ``check``.
|
and also that it takes more time than the default ``check``.
|
||||||
|
|
||||||
Alternatively, use the ``--read-data-subset`` parameter to check only a
|
Alternatively, use the ``--read-data-subset`` parameter to check only a subset
|
||||||
subset of the repository pack files at a time. It supports three ways to select a
|
of the repository pack files at a time. It supports three ways to select a
|
||||||
subset. One selects a specific range of pack files, the second selects a random
|
subset. One selects a specific part of pack files, the second and third
|
||||||
percentage of pack files, and the third selects pack files of the specified size.
|
selects a random subset of the pack files by the given percentage or size.
|
||||||
|
|
||||||
Use ``--read-data-subset=n/t`` to check only a subset of the repository pack
|
Use ``--read-data-subset=n/t`` to check a specific part of the repository pack
|
||||||
files at a time. The parameter takes two values, ``n`` and ``t``. When the check
|
files at a time. The parameter takes two values, ``n`` and ``t``. When the check
|
||||||
command runs, all pack files in the repository are logically divided in ``t``
|
command runs, all pack files in the repository are logically divided in ``t``
|
||||||
(roughly equal) groups, and only files that belong to group number ``n`` are
|
(roughly equal) groups, and only files that belong to group number ``n`` are
|
||||||
@ -268,33 +268,33 @@ over 5 separate invocations:
|
|||||||
$ restic -r /srv/restic-repo check --read-data-subset=4/5
|
$ restic -r /srv/restic-repo check --read-data-subset=4/5
|
||||||
$ restic -r /srv/restic-repo check --read-data-subset=5/5
|
$ restic -r /srv/restic-repo check --read-data-subset=5/5
|
||||||
|
|
||||||
Use ``--read-data-subset=n%`` to check a randomly choosen subset of the
|
Use ``--read-data-subset=x%`` to check a randomly choosen subset of the
|
||||||
repository pack files. It takes one parameter, ``n``, the percentage of pack
|
repository pack files. It takes one parameter, ``x``, the percentage of
|
||||||
files to check as an integer or floating point number. This will not guarantee
|
pack files to check as an integer or floating point number. This will not
|
||||||
to cover all available pack files after sufficient runs, but it is easy to
|
guarantee to cover all available pack files after sufficient runs, but it is
|
||||||
automate checking a small subset of data after each backup. For a floating point
|
easy to automate checking a small subset of data after each backup. For a
|
||||||
value the following command may be used:
|
floating point value the following command may be used:
|
||||||
|
|
||||||
.. code-block:: console
|
.. code-block:: console
|
||||||
|
|
||||||
$ restic -r /srv/restic-repo check --read-data-subset=2.5%
|
$ restic -r /srv/restic-repo check --read-data-subset=2.5%
|
||||||
|
|
||||||
When checking bigger subsets you most likely specify the percentage as an
|
When checking bigger subsets you most likely want to specify the percentage
|
||||||
integer:
|
as an integer:
|
||||||
|
|
||||||
.. code-block:: console
|
.. code-block:: console
|
||||||
|
|
||||||
$ restic -r /srv/restic-repo check --read-data-subset=10%
|
$ restic -r /srv/restic-repo check --read-data-subset=10%
|
||||||
|
|
||||||
Use ``--read-data-subset=NS`` to check a randomly chosen subset of the repository pack files.
|
Use ``--read-data-subset=nS`` to check a randomly chosen subset of the
|
||||||
It takes one parameter, ``NS``, where 'N' is a whole number representing file size and 'S' is the unit
|
repository pack files. It takes one parameter, ``nS``, where 'n' is a whole
|
||||||
of file size (B/K/M/G/T) of pack files to check. Behind the scenes, the specified size will be converted
|
number representing file size and 'S' is the unit of file size (K/M/G/T) of
|
||||||
to percentage of the total repository size. The behaviour of the check command following this conversion
|
pack files to check. Behind the scenes, the specified size will be converted
|
||||||
will be the same as the percentage option above. For a file size value the following command may be used:
|
to percentage of the total repository size. The behaviour of the check command
|
||||||
|
following this conversion will be the same as the percentage option above. For
|
||||||
|
a file size value the following command may be used:
|
||||||
|
|
||||||
.. code-block:: console
|
.. code-block:: console
|
||||||
|
|
||||||
$ restic -r /srv/restic-repo check --read-data-subset=50M
|
$ restic -r /srv/restic-repo check --read-data-subset=50M
|
||||||
$ restic -r /srv/restic-repo check --read-data-subset=10G
|
$ restic -r /srv/restic-repo check --read-data-subset=10G
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user