5858import java .nio .file .Files ;
5959import java .nio .file .Path ;
6060import java .nio .file .Paths ;
61+ import java .nio .file .StandardCopyOption ;
6162import java .nio .file .attribute .FileAttribute ;
6263import java .nio .file .attribute .PosixFilePermissions ;
6364import java .util .Collections ;
@@ -431,7 +432,7 @@ public void withCustomConfig(CheckedConsumer<Path, Exception> action) throws Exc
431432 Platforms .onLinux (() -> sh .run ("chown -R elasticsearch:elasticsearch " + tempDir ));
432433
433434 if (distribution .isPackage ()) {
434- Files .copy (installation .envFile , tempDir .resolve ("elasticsearch.bk" ));// backup
435+ Files .copy (installation .envFile , tempDir .resolve ("elasticsearch.bk" ), StandardCopyOption . COPY_ATTRIBUTES );// backup
435436 append (installation .envFile , "ES_PATH_CONF=" + tempConf + "\n " );
436437 } else {
437438 sh .getEnv ().put ("ES_PATH_CONF" , tempConf .toString ());
@@ -440,7 +441,7 @@ public void withCustomConfig(CheckedConsumer<Path, Exception> action) throws Exc
440441 action .accept (tempConf );
441442 if (distribution .isPackage ()) {
442443 IOUtils .rm (installation .envFile );
443- Files .copy (tempDir .resolve ("elasticsearch.bk" ), installation .envFile );
444+ Files .copy (tempDir .resolve ("elasticsearch.bk" ), installation .envFile , StandardCopyOption . COPY_ATTRIBUTES );
444445 } else {
445446 sh .getEnv ().remove ("ES_PATH_CONF" );
446447 }
0 commit comments