Create a Automatic script to upload files in google cloud storage

2.7k views Asked by At

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?

1

There are 1 answers

0
Chandra Mochahary On
#!/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