Message: 'Response code 403 (Forbidden)' when attempting to run ghost backup

When I attempt to run ghost backup from my webserver terminal, I’m presented with this error:

Love open source? We’re hiring JavaScript Engineers to work on Ghost full-time.
https://careers.ghost.org


+ sudo systemctl is-active ghost_mywebsite-com
+ sudo mkdir -p /var/www/mywebsite/backup
? Enter your Ghost administrator email address <redacted>
? Enter your Ghost administrator password [hidden]
✖ Backing up site
An error occurred.
Message: 'Response code 403 (Forbidden)'


Debug Information:
    OS: Ubuntu, v22.04.1 LTS
    Node Version: v16.17.1
    Ghost Version: 5.17.2
    Ghost-CLI Version: 1.23.1
    Environment: production
    Command: 'ghost backup'

Additional log info available in: /home/myuser/.ghost/logs/ghost-cli-debug-2022-10-17T22_46_27_575Z.log

Try running ghost doctor to check your system for known issues.

You can always refer to https://ghost.org/docs/ghost-cli/ for troubleshooting.

I desperately need to backup my install as I’m moving from Google Cloud Platform to self-hosting. Any ideas why this isn’t working?

The error log isn’t very useful for me, maybe it is for you?:

Debug Information:
    OS: Ubuntu, v22.04.1 LTS
    Node Version: v16.17.1
    Ghost Version: 5.17.2
    Ghost-CLI Version: 1.23.1
    Environment: production
    Command: 'ghost backup'
An error occurred.
Message: 'Response code 403 (Forbidden)'

Stack: HTTPError: Response code 403 (Forbidden)
    at EventEmitter.<anonymous> (/usr/lib/node_modules/ghost-cli/node_modules/got/source/as-stream.js:35:24)
    at EventEmitter.emit (node:events:513:28)
    at module.exports (/usr/lib/node_modules/ghost-cli/node_modules/got/source/get-response.js:22:10)
    at ClientRequest.handleResponse (/usr/lib/node_modules/ghost-cli/node_modules/got/source/request-as-event-emitter.js:155:5)
    at Object.onceWrapper (node:events:628:26)
    at ClientRequest.emit (node:events:525:35)
    at ClientRequest.origin.emit (/usr/lib/node_modules/ghost-cli/node_modules/@szmarczak/http-timer/source/index.js:37:11)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (node:_http_client:674:27)
    at HTTPParser.parserOnHeadersComplete (node:_http_common:128:17)
    at TLSSocket.socketOnData (node:_http_client:521:22)
    at TLSSocket.emit (node:events:513:28)
    at addChunk (node:internal/streams/readable:315:12)
    at readableAddChunk (node:internal/streams/readable:289:9)
    at TLSSocket.Readable.push (node:internal/streams/readable:228:10)
    at TLSWrap.onStreamRead (node:internal/stream_base_commons:190:23)
Path: /ghost/api/admin/db/

I’m not sure I know exactly what’s happening here. My first guess would be to ensure that your username and password are correct (judging from the error).

Alternatively, though, you can follow our guide on migrating from Ghost to Ghost, which doesn’t rely on the backup command: How to migrate data from Ghost to Ghost