chore: minor fix for distributed on deploy database backup in case of source folder and dest folder in different volumes issue
@@ -116,6 +116,7 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.AtomicMoveNotSupportedException;
+import java.nio.file.DirectoryNotEmptyException;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -1910,6 +1911,7 @@ public class ODistributedPlugin extends OServerPluginAbstract
"Backup folder configured as same of database folder:'%s'",
oldDirectory.getAbsolutePath()));
}
+ try {
try {
Files.move(
oldDirectory.toPath(), backupFullPath.toPath(), StandardCopyOption.ATOMIC_MOVE);
@@ -1926,6 +1928,25 @@ public class ODistributedPlugin extends OServerPluginAbstract
Files.move(oldDirectory.toPath(), Paths.get(backupPath, oldDirectory.getName()));
}
+ } catch (DirectoryNotEmptyException e) {
+ OLogManager.instance()
+ .errorNoDb(
+ this,
+ "File rename not supported during database backup, will try coping files",
+ null);
+ if (backupFullPath.exists()) {
+ deleteRecursively(backupFullPath);
+ }
+ Files.createDirectories(backupFullPath.toPath());
+ try {
+ OFileUtils.copyDirectory(
+ oldDirectory, Paths.get(backupPath, oldDirectory.getName()).toFile());
+ deleteRecursively(oldDirectory);
+ } catch (IOException ioe) {
+ OLogManager.instance().errorNoDb(this, "Error moving old database removing it", ioe);
+ deleteRecursively(oldDirectory);
+ }
+ }
}
} catch (IOException e) {
ODistributedServerLog.warn(
