Nextcloud.export does not work when called by cron

Nextcloud version: snap version
Operating system and version: Ubuntu 22.04
Apache version: 2.4 according to
PHP version: 8.2 according to

The issue you are facing:
nextcloud.export doesn’t work when called (in a script) by cron

Is this the first time you’ve seen this error?: Yes

Steps to replicate it:

  1. nextcloud.export works
  2. nextcloud.export works in a script when I run the script manually
  3. nextcloud.export doesn’t export anything when the script is called by cron

My root crontab is:
0 */1 * * * /root/

BUT I have a second script called If I call that script with cron, then the nextcloud.export runs beautifully.


#!/usr/bin/env bash
/root/ | mail -s "backup output"

Hope that is clear. The export command works if I run the script manually, but it does not if the script is called from a cronjob. But it DOES if I make another script that calls it. Thanks in advance!

EDIT: I also noticed from the logs that when nextcloud.export is called by crond via a script, the config is not exported. But, again, if the same script is executed manually, the config is exported fine. Here is the message in the log showing the failure:

Exporting config...
Unable to export config

All very mysterious! Maybe it’s my lack of depth of understanding of how crond works…

Hi @cuorie,

assuming you’ve changed the data directory, we’ve seen similar issues.

see also the developers note in code

check out the alternative backup, restore & migrate method. this snap export script is known to work, but the snap snaphot method is recommended,