Skip to content

Commit

Permalink
Copy attributes when backing up and restoring custom configurations (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
williamrandolph committed Oct 14, 2020
1 parent e6d04dc commit 7ff676c
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.nio.file.attribute.FileAttribute;
import java.nio.file.attribute.PosixFilePermissions;
import java.util.Collections;
Expand Down Expand Up @@ -431,7 +432,7 @@ public void withCustomConfig(CheckedConsumer<Path, Exception> action) throws Exc
Platforms.onLinux(() -> sh.run("chown -R elasticsearch:elasticsearch " + tempDir));

if (distribution.isPackage()) {
Files.copy(installation.envFile, tempDir.resolve("elasticsearch.bk"));// backup
Files.copy(installation.envFile, tempDir.resolve("elasticsearch.bk"), StandardCopyOption.COPY_ATTRIBUTES);// backup
append(installation.envFile, "ES_PATH_CONF=" + tempConf + "\n");
} else {
sh.getEnv().put("ES_PATH_CONF", tempConf.toString());
Expand All @@ -440,7 +441,7 @@ public void withCustomConfig(CheckedConsumer<Path, Exception> action) throws Exc
action.accept(tempConf);
if (distribution.isPackage()) {
IOUtils.rm(installation.envFile);
Files.copy(tempDir.resolve("elasticsearch.bk"), installation.envFile);
Files.copy(tempDir.resolve("elasticsearch.bk"), installation.envFile, StandardCopyOption.COPY_ATTRIBUTES);
} else {
sh.getEnv().remove("ES_PATH_CONF");
}
Expand Down

0 comments on commit 7ff676c

Please sign in to comment.