diff --git a/src/backupformat/tgz.js b/src/backupformat/tgz.js index 66247adab..b90057d1c 100644 --- a/src/backupformat/tgz.js +++ b/src/backupformat/tgz.js @@ -100,7 +100,7 @@ async function tarPack(dataLayout, encryption, uploader, progressCallback) { if (!handle) { debug(`tarPack: skipping file, could not open ${abspath}: ${openError.message}`); continue; } const [statError, stat] = await safe(handle.stat()); if (!stat) { debug(`tarPack: skipping file, could not stat ${abspath}: ${statError.message}`); continue; } - const header = { name: headerName, type: 'file', size: stat.size, uid: process.getuid(), gid: process.getgid() }; + const header = { name: headerName, type: 'file', mode: stat.mode, size: stat.size, uid: process.getuid(), gid: process.getgid() }; if (stat.size > 8589934590 || entry.name.length > 99) header.pax = { size: stat.size }; const input = handle.createReadStream({ autoClose: true }); await addToPack(pack, header, { input }); @@ -152,6 +152,7 @@ async function tarExtract(inStream, dataLayout, encryption, progressCallback) { } else if (header.type === 'file') { const output = fs.createWriteStream(abspath); [error] = await safe(stream.pipeline(entryStream, output)); + if (!error) [error] = await safe(fs.promises.chmod(abspath, header.mode)); } else if (header.type === 'symlink') { await safe(fs.promises.unlink(abspath)); // remove any link created from previous failed extract [error] = await safe(fs.promises.symlink(header.linkname, abspath));