diff --git a/src/storage/filesystem.js b/src/storage/filesystem.js index 5d36f47a0..a305124eb 100644 --- a/src/storage/filesystem.js +++ b/src/storage/filesystem.js @@ -187,8 +187,27 @@ async function copy(apiConfig, oldFilePath, newFilePath, progressCallback) { let cpOptions = ((apiConfig.provider !== PROVIDER_MOUNTPOINT && apiConfig.provider !== PROVIDER_CIFS) || apiConfig.preserveAttributes) ? '-a' : '-dR'; cpOptions += apiConfig.noHardlinks ? '' : 'l'; // this will hardlink backups saving space - const [copyError] = await safe(shell.execArgs('copy', 'cp', [ cpOptions, oldFilePath, newFilePath ], {})); - if (copyError) throw new BoxError(BoxError.EXTERNAL_ERROR, copyError.message); + if (apiConfig.provider === PROVIDER_SSHFS) { + const identityFilePath = `/home/yellowtent/platformdata/sshfs/id_rsa_${apiConfig.mountOptions.host}`; + + const sshOptions = []; + sshOptions.push('-o'); + sshOptions.push('"StrictHostKeyChecking no"'); + sshOptions.push('-i'); + sshOptions.push(identityFilePath); + sshOptions.push('-p'); + sshOptions.push(apiConfig.mountOptions.port); + sshOptions.push(`${apiConfig.mountOptions.user}@${apiConfig.mountOptions.host}`); + + oldFilePath = oldFilePath.replace('/mnt/cloudronbackup/', ''); + newFilePath = newFilePath.replace('/mnt/cloudronbackup/', ''); + + const [copyError] = await safe(shell.execArgs('copy', 'ssh', sshOptions.concat([ 'cp', cpOptions, oldFilePath, newFilePath ]), { shell: true })); + if (copyError) throw new BoxError(BoxError.EXTERNAL_ERROR, copyError.message); + } else { + const [copyError] = await safe(shell.execArgs('copy', 'cp', [ cpOptions, oldFilePath, newFilePath ], {})); + if (copyError) throw new BoxError(BoxError.EXTERNAL_ERROR, copyError.message); + } } async function remove(apiConfig, filename) {