I built a shell-script (copy-paste-edit …) to sync a local sftp repository to a google cloud storage repository.
This shell script works when called from the shell (as root). When I call it from cron or a systemd-timer I get things like (anonymized quote):
ERROR can't connect to storage: unable to list from the bucket: ListBlobs: Get "https://storage.googleapis.com/storage/v1/b/somebucket/o?alt=json&delimiter=&endOffset=&includeTrailingDelimiter=false&pageToken=&prefix=kopia-gcs-storage-initializing-168914646xxxxxxx&prettyPrint=false&projection=full&startOffset=&versions=false": oauth2: cannot fetch token: Post "https://oauth2.googleapis.com/token": dial tcp 142.250.185.202:443: i/o timeout
The relevant part in the script:
$KOPIA repository sync-to gcs \
--credentials-file "/root/somekey.json" \
--bucket "somebucket" \
--max-upload-speed=948576 \
--no-delete \
--no-update \
--disable-color
As mentioned: it works on the shell. So I assume some environment variables might miss. While I type this I think of $http_proxy etc … I will test in that direction.