To run Gsutil with Cron, full path is required

When Gsutil is run manually by the shell, the full path is not required. So, the command

gsutil rsync /var/www/BACKUP gs://mybucket

is sufficient. However, the cron requires the full path.

The path can be located with the command

gsutil version -l

This yields the output

root@server:/var/www# gsutil version -l
gsutil version: 5.21
checksum: 74f2cab932617e89e1a88b1b346339f7 (OK)
boto version: 2.49.0
python version: 3.6.9 (default, Mar 10 2023, 16:46:00) [GCC 8.4.0]
OS: Linux 4.15.0-208-generic
multiprocessing available: True
using cloud sdk: True
pass cloud sdk credentials to gsutil: True
config path(s): /root/.boto, /root/.config/gcloud/legacy_credentials/demo@gmail.com/.boto, /root/.aws/credentials
gsutil path: /root/google-cloud-sdk/bin/gsutil
compiled crcmod: False
installed via package manager: False
editable install: False
shim enabled: False

In the bash file, the command has to be

/root/google-cloud-sdk/bin/gsutil rsync /var/www/BACKUP gs://mybucket

The same thing is true for the AWS S3.

The command is

/usr/local/bin/aws s3 sync /var/www/BACKUP/ s3://mybucket/

Leave a Reply

Your email address will not be published. Required fields are marked *