Browse code

BM-11206 Fix: try to avoid dataprotect + NFS ownership issues

Vincent Vignaud authored on 05/02/2019 09:20:52
Showing 3 changed files
... ...
@@ -158,6 +158,12 @@ public class MboxRestoreService {
158 158
 			return;
159 159
 		}
160 160
 
161
+		// ensure mbox files are owned by cyrus:mail
162
+		boxFsFolders.allFolders().forEach(f -> {
163
+			logger.debug(String.format("Ensure cyrus:mail ownership on '%s' and sub-files", f));
164
+			NCUtils.exec(nc, String.format("chown -R cyrus:mail '%s'", f));
165
+		});
166
+
161 167
 		String recon = "/usr/sbin/reconstruct -r -f -R -G -I " + BoxFsFolders.namespace(mbox) + box.name + "@"
162 168
 				+ domain.uid;
163 169
 		logger.info("Reconstruct command: " + recon);
... ...
@@ -52,7 +52,6 @@ import net.bluemind.dataprotect.service.IDPContext;
52 52
 import net.bluemind.dataprotect.service.IDPContext.IToolConfig;
53 53
 import net.bluemind.dataprotect.service.IDPContext.IToolSession;
54 54
 import net.bluemind.dataprotect.service.tool.ToolBootstrap;
55
-import net.bluemind.node.api.ExitList;
56 55
 import net.bluemind.node.api.FileDescription;
57 56
 import net.bluemind.node.api.INodeClient;
58 57
 import net.bluemind.node.api.NCUtils;
... ...
@@ -344,13 +343,6 @@ public class SaveAllTask implements IServerTask {
344 343
 						setupIsOk = false;
345 344
 						monitor.log("/var/backups/bluemind/ is not shared on " + iv.value.address());
346 345
 					}
347
-					NCUtils.execNoOut(nc, "chown 2:2 " + fn);
348
-					ExitList el = NCUtils.exec(nc, "chown 42:42 " + fn);
349
-					if (el.getExitCode() != 0) {
350
-						setupIsOk = false;
351
-						monitor.log(
352
-								"Your /var/backups/bluemind/ does not preserve uids/guids. Check the documentation for NFS mount options.");
353
-					}
354 346
 				}
355 347
 			} catch (Exception e) {
356 348
 				logger.error(e.getMessage());
... ...
@@ -82,7 +82,7 @@ public class ToolSession implements IToolSession {
82 82
 
83 83
 		StringBuilder cmd = new StringBuilder();
84 84
 		cmd.append(
85
-				"/usr/share/bm-node/rsync-backup.sh --exclude-from=/etc/bm-node/rsync.excludes -a --delete --numeric-ids --relative --delete-excluded");
85
+				"/usr/share/bm-node/rsync-backup.sh --exclude-from=/etc/bm-node/rsync.excludes -rltD --delete --numeric-ids --relative --delete-excluded");
86 86
 		if (previous != null) {
87 87
 			cmd.append(" --link-dest=");
88 88
 			appendDir(cmd).append(previous.id).append('/');