diff --git a/doc/manual/command-ref/nix-store.xml b/doc/manual/command-ref/nix-store.xml
index 41a04f265..d73cb92ee 100644
--- a/doc/manual/command-ref/nix-store.xml
+++ b/doc/manual/command-ref/nix-store.xml
@@ -1282,6 +1282,7 @@ ktorrent-2.2.1/NEWS
nix-store
+ paths
@@ -1292,6 +1293,13 @@ Nix database to standard output. It can be loaded into an empty Nix
store using . This is useful for making
backups and when migrating to different database schemas.
+By default, will dump the entire Nix
+database. When one or more store paths is passed, only the subset of
+the Nix database for those store paths is dumped. As with
+, the user is responsible for passing all the
+store paths for a closure. See for an
+example.
+
diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc
index a9ad14762..33138baff 100644
--- a/src/nix-store/nix-store.cc
+++ b/src/nix-store/nix-store.cc
@@ -485,11 +485,16 @@ static void opReadLog(Strings opFlags, Strings opArgs)
static void opDumpDB(Strings opFlags, Strings opArgs)
{
if (!opFlags.empty()) throw UsageError("unknown flag");
- if (!opArgs.empty())
- throw UsageError("no arguments expected");
- PathSet validPaths = store->queryAllValidPaths();
- for (auto & i : validPaths)
- cout << store->makeValidityRegistration({i}, true, true);
+ if (!opArgs.empty()) {
+ for (auto & i : opArgs)
+ i = store->followLinksToStorePath(i);
+ for (auto & i : opArgs)
+ cout << store->makeValidityRegistration({i}, true, true);
+ } else {
+ PathSet validPaths = store->queryAllValidPaths();
+ for (auto & i : validPaths)
+ cout << store->makeValidityRegistration({i}, true, true);
+ }
}