0

I create a script to automatically upload my files to google cloud storage, my vm is in the same project as my Google Cloud Bucket... So I create this script but I can't run it properly

#!/bin/bash
TIME=`date +%b-%d-%y`
FILENAME=backup-$TIME.tar.gz
SRCDIR=opt/R
DESDIR= gsutil gs cp FILENAME -$TIME.tar.gz  gs://my-storage-name
tar -cpzf $DESDIR/$FILENAME $SRCDIR

any help?

Toto
  • 89,455
  • 62
  • 89
  • 125
gabb00
  • 23
  • 4
  • Please paste your script at [shellcheck.net](http://www.shellcheck.net/) and try to implement the recommendations made there. – Cyrus Jun 08 '21 at 20:31
  • I suggest reviewing how to upload an object using `gsutil`: https://cloud.google.com/storage/docs/uploading-objects#gsutil – Donnald Cucharo Jun 09 '21 at 01:36

1 Answers1

0
#!/bin/bash
TIME=`date +%b-%d-%y`
FILENAME=backup-$TIME.tar.gz
gsutil cp {path of the source-file} gs://my-storage-name/backup-$TIME.tar.gz

It will save your file with the name of backup-$TIME.tar.gz

eg.backup-Jun-09-21.tar.gz