Skip to content

Commit

Permalink
fix(backup): swap to using @tryghost/zip
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ErisDS committed May 19, 2022
1 parent 0cbb492 commit 3eca000
Show file tree
Hide file tree
Showing 3 changed files with 207 additions and 15 deletions.
9 changes: 2 additions & 7 deletions lib/tasks/backup.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const path = require('path');
const zip = require('@tryghost/zip');

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

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

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

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
},
"preferGlobal": true,
"dependencies": {
"@tryghost/zip": "^1.1.25",
"abbrev": "1.1.1",
"adm-zip": "0.5.9",
"bluebird": "3.7.2",
Expand Down
Loading

0 comments on commit 3eca000

Please sign in to comment.