jotta / jotta-cli-issues

45 stars 1 forks source link

jotta-cli download via crontab not working in latest release #164

Closed ctvedt closed 1 year ago

ctvedt commented 3 years ago

Make sure you are running the latest version of jotta-cli before reporting an issue.

jotta-cli release (jotta-cli version): 0.12.50392

Description of problem: jotta-cli download not working via crontab. This was working fine prior to latest version, and I can not figure out how to get it working again. Manual download is working just fine.

crontab for my user (non-root): */5 * * * * jotta-cli download --merge backup/path/ /home/ctvedt/path/ > /home/ctvedt/jottadownload.log

this results in:

> starting download backup/path => /home/ctvedt/path
> gathering metadata ... (ctrl-C to cancel)
> encountered error while gathering metadata..

Expected: If i run the same command from shell, it works fine and as expected:

> starting download backup/path => /home/ctvedt/path
> gathering metadata ... (ctrl-C to cancel)
> 1 files (920.73KiB) found in 234.900885ms       
started download 4a52961ce0
  run 'jotta-cli download --abort=4a52961ce0' to cancel
  run 'jotta-cli observe --downloadid=4a52961ce0' to view progress
  or see 'jotta-cli list downloads' for information about 
  all current, queued or failed downloads

jotta-cli status (jotta-cli status):

N/A

Relevant logs for the issue (~/.jottad/jottabackup.log or /var/lib/jotta/jottabackup.log )

N/A

Traceback

N/A

Additional info:

Kimbsen commented 3 years ago

Hi. We did change how jottad and jotta-cli communicate with that release. If you take a look at the solution posted here https://github.com/jotta/jotta-cli-issues/issues/162 i think doing something similar will resolve your issue. There is more information about that change under the release notes posted for version 0.12.50392 here: https://docs.jottacloud.com/en/articles/1461561-release-notes-for-jottacloud-cli

ctvedt commented 3 years ago

Thanks, I got it working again, but had to move the job from non-root user crontab to root crontab. Any plans on making this work again with non-root cron in the future?

For other people struggling with the same issue, this is how I solved it (where ctvedt is the non-root user)

sudo crontab -e
*/5  * * * * su --login ctvedt -c "XDG_RUNTIME_DIR=/run/user/$(id -u ctvedt) jotta-cli download --merge backup/path/ /home/ctvedt/path/ > /home/ctvedt/jottadownload.log"
existemi commented 3 years ago

You don’t need to use root and execute with su from your crontab. The important thing is to make sure you set XDG_RUNTIME_DIR. You can set that variable directly at the top of your crontab to have it available for any and all commands you have.