I have read the documentation for Google Cloud Storage(GCS) and I am very confused.
Let me describe the situation:
Before I am using a simple php script to back up data from and SQL Table. At every one hour. Afterwards I sent it to my ftp server. Now Now I would like instead to be sent to a google nearline cold storage.
Before the script was simple, nothing fancy just a little PHP
passthru('curl --connect-timeout 30 --max-time 3600 -T '.$file_path.' "ftp://'.$ftp_server['user'].':'.$ftp_server['pass'].'@'.$ftp_server['ip'].':'.$ftp_server['port'].$ftp_server['path'].'/'.$filename.'.gz"', $status_result);
Now I read the google cloud API and I am very confused of actually how to change my PHP script, so that it sends the gz files to the nearline cold storage.
I read this: https://developers.google.com/api-client-library/php/
and I have the following questions
It says that I have to include the google API, how do I do that? In the example it said that I should use the command "$ composer require google/cloud" and then write in my PHP files: "use Google\Cloud\ServiceBuilder;" But I haven't use composer on the server. The server is written on pure PHP.
Thank you in advance
Why not just keep using a little script? GCE comes with gsutil
installed, which you can use to transfer files to GCS. Try this:
passthru('gsutil cp '.$filepath.' gs://bucket/', $status_result);
Note that, for auth to work, you'll have to make sure your instance's service account is scoped to access GCS, see: https://cloud.google.com/compute/docs/access/create-enable-service-accounts-for-instances#changeserviceaccountandscopes