diff --git a/src/sftp.js b/src/sftp.js index f0adc1a93..d46ba7fe0 100644 --- a/src/sftp.js +++ b/src/sftp.js @@ -10,6 +10,7 @@ var apps = require('./apps.js'), async = require('async'), debug = require('debug')('box:sftp'), infra = require('./infra_version.js'), + safe = require('safetydance'), shell = require('./shell.js'); function startSftp(existingInfra, callback) { @@ -45,10 +46,14 @@ function rebuild(options, callback) { return; } - dataDirs.push({ - hostDir: apps.getDataDir(app, app.dataDir), - mountDir: `/app/data/${app.id}` - }); + const hostDir = apps.getDataDir(app, app.dataDir), mountDir = `/app/data/${app.id}`; + if (!safe.fs.existsSync(hostDir)) { + // do not create host path when cloudron is restoring. this will then create dir with root perms making restore logic fail + debug(`Ignoring volume for ${app.id} since it does not exist`); + return; + } + + dataDirs.push({ hostDir, mountDir }); }); debug('app volume mounts', dataDirs);