Skip to content

Commit 3eca000

Browse files
committed
fix(backup): swap to using @tryghost/zip
refs: TryGhost/Toolbox#334 refs: #468 - zip is meant to be installed on ubuntu 18 but for some reason on DO it is not - use our JS lib instead, as that will work on any platform, although it may have issues with scaling
1 parent 0cbb492 commit 3eca000

File tree

3 files changed

+207
-15
lines changed

3 files changed

+207
-15
lines changed

lib/tasks/backup.js

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const path = require('path');
2+
const zip = require('@tryghost/zip');
23

34
const debug = require('debug')('ghost-cli:backup');
4-
const execa = require('execa');
55
const fs = require('fs-extra');
66

77
const ghostUser = require('../utils/use-ghost-user');
@@ -74,13 +74,8 @@ module.exports = async function (ui, instance) {
7474
const zipPath = path.join(process.cwd(), `backup-${backupSuffix}.zip`);
7575

7676
try {
77-
execa.shellSync(`zip -r ${zipPath} data/${membersExportFile} data/${membersExportFile} files/ images/ media/ settings/ themes/`, {
78-
cwd: path.join(instance.dir, 'content/')
79-
});
77+
await zip.compress(path.join(instance.dir, 'content/'), zipPath, {glob: `{data/${contentExportFile},data/${membersExportFile},files/**,images/**,media/**,settings/**,themes/**}`});
8078
} catch (err) {
81-
if (err.stderr.match(/zip.*?not found/)) {
82-
err.message = `Package zip was not found. Please install by running \`sudo apt install zip\`. \n${err.message}`;
83-
}
8479
throw new ProcessError(err);
8580
}
8681

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
},
4444
"preferGlobal": true,
4545
"dependencies": {
46+
"@tryghost/zip": "^1.1.25",
4647
"abbrev": "1.1.1",
4748
"adm-zip": "0.5.9",
4849
"bluebird": "3.7.2",

0 commit comments

Comments
 (0)