Attempt server side copy on sshfs via ssh exec

only so far tested agains hetzner storage boxes which apparently run BSD
unix tools
This commit is contained in:
Johannes Zellner
2024-07-02 19:02:36 +02:00
parent a363e508b6
commit d122ece8e9

View File

@@ -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) {