backups: when checking mount status, ignore the prefix
This commit is contained in:
@@ -77,14 +77,23 @@ async function checkBackupPreconditions(apiConfig, dataLayout) {
|
||||
assert.strictEqual(typeof apiConfig, 'object');
|
||||
assert(dataLayout instanceof DataLayout, 'dataLayout must be a DataLayout');
|
||||
|
||||
const [error, rootPath] = await safe(df.file(getBackupRootPath(apiConfig)));
|
||||
let backupRootPath;
|
||||
if (apiConfig.provider === PROVIDER_SSHFS || apiConfig.provider === PROVIDER_CIFS || apiConfig.provider === PROVIDER_NFS || apiConfig.provider === PROVIDER_EXT4 || apiConfig.provider === PROVIDER_XFS) {
|
||||
backupRootPath = paths.MANAGED_BACKUP_MOUNT_DIR;
|
||||
} else if (apiConfig.provider === PROVIDER_MOUNTPOINT) {
|
||||
backupRootPath = paths.apiConfig.mountpoint;
|
||||
} else {
|
||||
backupRootPath = apiConfig.backupFolder;
|
||||
}
|
||||
|
||||
const [error, dfResult] = await safe(df.file(backupRootPath)); // without prefix in case it's not mounted at all
|
||||
if (error) throw new BoxError(BoxError.FS_ERROR, `Error when checking for disk space: ${error.message}`);
|
||||
|
||||
// Check filesystem is mounted so we don't write into the actual folder on disk
|
||||
if (apiConfig.provider === PROVIDER_SSHFS || apiConfig.provider === PROVIDER_CIFS || apiConfig.provider === PROVIDER_NFS || apiConfig.provider === PROVIDER_EXT4 || apiConfig.provider === PROVIDER_XFS) {
|
||||
if (rootPath.mountpoint !== paths.MANAGED_BACKUP_MOUNT_DIR) throw new BoxError(BoxError.FS_ERROR, 'Backup target is not mounted');
|
||||
if (dfResult.mountpoint !== paths.MANAGED_BACKUP_MOUNT_DIR) throw new BoxError(BoxError.FS_ERROR, 'Backup target is not mounted');
|
||||
} else if (apiConfig.provider === PROVIDER_MOUNTPOINT) {
|
||||
if (rootPath.mountpoint === '/') throw new BoxError(BoxError.FS_ERROR, `${apiConfig.backupFolder} is not mounted`);
|
||||
if (dfResult.mountpoint === '/') throw new BoxError(BoxError.FS_ERROR, `${apiConfig.backupFolder} is not mounted`);
|
||||
}
|
||||
|
||||
let used = 0;
|
||||
@@ -98,7 +107,7 @@ async function checkBackupPreconditions(apiConfig, dataLayout) {
|
||||
debug(`checkBackupPreconditions: ${used} bytes`);
|
||||
|
||||
const needed = 0.6 * used + (1024 * 1024 * 1024); // check if there is atleast 1GB left afterwards. aim for 60% because rsync/tgz won't need full 100%
|
||||
if (rootPath.available <= needed) throw new BoxError(BoxError.FS_ERROR, `Not enough disk space for backup. Needed: ${prettyBytes(needed)} Available: ${prettyBytes(rootPath.available)}`);
|
||||
if (dfResult.available <= needed) throw new BoxError(BoxError.FS_ERROR, `Not enough disk space for backup. Needed: ${prettyBytes(needed)} Available: ${prettyBytes(dfResult.available)}`);
|
||||
}
|
||||
|
||||
function hasChownSupportSync(apiConfig) {
|
||||
|
||||
Reference in New Issue
Block a user