1

I made a Virtual Machine using Google Cloud's Debian GNU/Linux 9 server. In there, I have a script that writes and saves to an Excel (xlsx) file at a certain time every day. I have tmux installed so that it keeps running the script when I shut my pc off.

Is there a way for me to retreive this information in an easy way instead of me having to open up the server and downloading it from there. It kind of defeats the whole purpose of me making a bot. :/

Thanks!

Ps. I'm on a Windows10 desktop

Serhii Rohoza
  • 4,287
  • 2
  • 16
  • 29

1 Answers1

0

As a possible solution you can follow steps below:

  1. create a bucket at Google Storage

  2. install gcsfuse

  3. mount your bucket to the VM as a file system with Cloud Storage FUSE:

    bucket-fuse-mount:~$ gcsfuse bucket-fuse-mount /home/user/bucket-fuse-mount/
    Using mount point: /home/user/bucket-fuse-mount
    Opening GCS connection...
    Opening bucket...
    Mounting file system...
    File system has been successfully mounted.
    
  4. check if you can write to mounted bucket:

    bucket-fuse-mount:~$ touch /home/user/bucket-fuse-mount/test-file
    touch: cannot touch '/home/user/bucket-fuse-mount/test-file': Input/output error
    

    if you see the same error go to Compute Engine -> VM instances -> stop your VM -> click on NAME_OF_VM_INSTANCE -> click EDIT -> go to Access scopes -> select Set access for each API -> find Storage and change Read Only to Full as result Cloud Storage FUSE will be able use the Compute Engine built-in service account -> start VM -> mount the bucket and check again:

    bucket-fuse-mount:~$ touch /home/user/bucket-fuse-mount/test-file
    bucket-fuse-mount:~$
    bucket-fuse-mount:~$ ls -l /home/user/bucket-fuse-mount/
    total 0
    -rw-r--r-- 1 user user 0 Apr  4 19:15 test-file
    
  5. save .xlsx files to the mounted bucket (just change path in your script)

  6. download files from the bucket with gsutil command directly from Windows (gsutil command is a part of Google Cloud SDK):

    gsutil cp gs://[BUCKET_NAME]/[OBJECT_NAME] [SAVE_TO_LOCATION]
    

    for me it looks like:

    gsutil cp gs://bucket-fuse-mount/test-file test-file 
    Copying gs://bucket-fuse-mount/test-file...
    / [1 files][    0.0 B/    0.0 B]                                                
    Operation completed over 1 objects. 
    

    no connections to your server needed.

In addition, you can upload files to your VM in the same way.

Serhii Rohoza
  • 4,287
  • 2
  • 16
  • 29
  • Thanks for your answer! I do however believe I am missing permission to acces that mounted file from my script. ```OSError: [Errno 5] Input/output error: '/home/wmj_donkers/mount/Koersen.xlsx'```. I've tried ```sudo chmod 755 -R /home/wmj_donkers/mount``` but permission is then, once again, denied. – Wouter Donkers Apr 04 '20 at 13:28
  • I was able to replicate similar error. I've updated my answer with extra instructions. – Serhii Rohoza Apr 04 '20 at 19:22
  • Thanks so much, you've been a great help! Everything seems to be working! My python script is running in the background and the Excel file is being updated. I just can't seem to get my gsutil command working. I think it can't find a path to my python programme. ```ERROR: (gsutil) "C:\Users\User\AppData\Local\Programs\Python\Python38-32\python.exe": command not found``` – Wouter Donkers Apr 05 '20 at 14:13
  • I tried upvoting your answer but I'm new to the platform and haven't got 15 reputation yet ;) – Wouter Donkers Apr 05 '20 at 14:18
  • Thank you! You've accepted my answer and I appreciate it. About your error related to python, please have a look at this [question](https://stackoverflow.com/questions/60405013) - it could be helpful for you. – Serhii Rohoza Apr 05 '20 at 20:36
  • Thanks so much, I got everything working the way it should work! In an attempt to finish my project I asked one final question here: if you could help me out, once again, that'd be awesome! – Wouter Donkers Apr 08 '20 at 14:31