Copy Files From Apache to Google Cloud Storage

This short tutorial shows you how to copy files from your Apache webserver on the Google Compute Engine to your cloud storage.

The first hurdle is giving access to your projects cloud storage to your VM. By default your VM instance is not given access to cloud storage so you will need to give it permission.

  1. Stop your instance. ( This will take a little bit )
  2. Click your instance name to see the options.
  3. Click “Edit”.
  4. Scroll Down to Service Account.
  5. Select the custom option to adjust settings for each service.
  6. Find “Storage” and change the permissions to “Full”.
  7. Click “Save”
  8. Start your instance

Now give it a few minutes for the new permissions to propagate.

Log into you server via SSH and use the following command to copy the the desired files:

gsutil cp /path/to/file/filename gs://your-bucket/

If you want to transfer off the files in a directory to your bucket:

gsutil cp /path/to/directory/directory name/* gs://your-bucket/

On a side note, if you haveĀ A.D.D. like me, and like to use sub folders with spaces in the name like “My Cool Folder” you can make it work by escaping the spaces like this:

gsutil cp /path/to/directory/directory name/* gs://your-bucket/My\ Cool\ Folder


Leave a comment