0

I am having errors while running duplicity in macOS (crontab)

The duplicity command is as follows (works in Command-line)

/usr/local/bin/duplicity /Users/myname/go file:///Volumes/EVO840\ -\ IMPORTANT/DuplicityGo/ --exclude '**/bin/***' --exclude '**/pkg'

When using crontab -e (with and without sudo),

* * * * * /Users/myname/bashscripts/duplicity.sh > /Users/myname/bashscripts/duplicity.log 2>&1

it returns following error

Traceback (innermost last):
  File "/usr/local/bin/duplicity", line 87, in <module>
    with_tempdir(main)
  File "/usr/local/bin/duplicity", line 72, in with_tempdir
    tempdir.default().cleanup()
  File "/usr/local/Cellar/duplicity/0.8.23/libexec/lib/python3.9/site-packages/duplicity/tempdir.py", line 69, in default
    _defaultInstance = TemporaryDirectory(temproot=config.temproot)
  File "/usr/local/Cellar/duplicity/0.8.23/libexec/lib/python3.9/site-packages/duplicity/tempdir.py", line 155, in __init__
    temproot = subprocess.check_output([u'getconf', u'DARWIN_USER_TEMP_DIR'])
  File "/usr/local/Cellar/python@3.9/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 424, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/local/Cellar/python@3.9/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 505, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/local/Cellar/python@3.9/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/local/Cellar/python@3.9/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 1821, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
 FileNotFoundError: [Errno 2] No such file or directory: 'getconf'

Attempt of list Nr. 1 failed. PermissionError: Operation not permitted
Attempt of list Nr. 3 failed. PermissionError: Operation not permitted
Attempt of list Nr. 4 failed. PermissionError: Operation not permitted

Someone Special
  • 171
  • 2
  • 8
  • By default not every OSX application has "full disk access" permissions and `cron` doesn't have that either. See for example https://osxdaily.com/2020/04/27/fix-cron-permissions-macos-full-disk-access/ – HBruijn Aug 15 '22 at 07:26
  • Thank you very much for quick answer. I tried adding cron, as well as duplicity to Full Disk Access, and unfortunately, error still exist for `No such file or directory: 'getconf'` – Someone Special Aug 15 '22 at 08:42
  • The second problem: https://serverfault.com/q/449651/37681 – HBruijn Aug 15 '22 at 09:13
  • I figured out the problem was due to using external volumes. Thanks for your help. – Someone Special Aug 15 '22 at 12:04

2 Answers2

0

cron often has no or a limited PATH env var set only. set it on top of your crontab to the same value you use in your commandline and the error will likely vanish.

0

I found out that the problem arises from me using Removable Volume as destination for duplicity.

In order for my bash script to work (or even just running duplicity in crontab), I have to add /bin/bash to Full Disk Access (though, I think it's feels unsafe)

Someone Special
  • 171
  • 2
  • 8