jacksegal/google-compute-snapshot

Error after snapshot creation

Closed this issue · 6 comments

2017-09-27 21:27:19: Start of Script
2017-09-27 21:27:19: Start of createSnapshotWrapper
Creating snapshot(s) gcs-growecewebsite-6778689268549088110-1506500839...
.......................done.
2017-09-27 21:27:41: Start of deleteSnapshotsWrapper
bash: line 1: syntax error near unexpected token (' bash: line 1: /usr/local/share/google/google-cloud-sdk/bin/gcloud compute snapshots list --regexp (gcs-.6778689268549088110-.) --uri'
2017-09-27 21:27:41: End of Script

Hi there,

It looks like the parentheses (which is for passing param to function) is being included in the actual string for one of the commands.

I've made a change in a new branch which might fix it - please can you follow the instructions below and let me know if it works for you:

cd ~
wget https://raw.githubusercontent.com/jacksegal/google-compute-snapshot/issue-25/gcloud-snapshot.sh
chmod +x gcloud-snapshot.sh
sudo mkdir -p /opt/google-compute-snapshot
sudo mv gcloud-snapshot.sh /opt/google-compute-snapshot/test-gcloud-snapshot.sh
sudo /opt/google-compute-snapshot/test-gcloud-snapshot.sh

If you are interested, the issue is that the command should be: gcloud compute snapshots list --regexp gcs-.6778689268549088110-. --uri

But your command says: gcloud compute snapshots list --regexp (gcs-.6778689268549088110-.) --uri

I think the parentheses is coming from line 281: getSnapshots "(gcs-.*${DEVICE_ID}-.*)" - I've removed the parentheses, so that the line now reads: getSnapshots "gcs-.*${DEVICE_ID}-.*"

Let me know how you get on,
Jack

Hi Jack.

CentOS release 6.9 (Final) x86_64
bash-4.1.2-48.el6.x86_64

Thanks for getting back to me on this.. I'd had a look at this script a couple of months back and had the same problem on other Centos instances...

2017-09-28 07:40:04: Start of Script
2017-09-28 07:40:04: Start of createSnapshotWrapper
Creating snapshot(s) gcs-growecewebsite-6778689268549088110-1506537604...
.....................done.
2017-09-28 07:40:24: Start of deleteSnapshotsWrapper
date: invalid date 2017-09-27T01:24:24.787-07:00' ./gcloud-snapshot.sh: line 211: [: 20170921: unary operator expected date: invalid date 2017-09-27T01:27:21.835-07:00'
./gcloud-snapshot.sh: line 211: [: 20170921: unary operator expected
date: invalid date `2017-09-27T11:40:06.566-07:00'
./gcloud-snapshot.sh: line 211: [: 20170921: unary operator expected
2017-09-28 07:40:27: End of Script

Okay, well at least it got further this time.

Must be a difference between CentOs and Debian on how they use dates.

I'll try and find a fix.

@aaronsinclair,

I finally found some time to look at it and I think I've fixed it - if you pull down the other branch again it should work:

cd ~
wget https://raw.githubusercontent.com/jacksegal/google-compute-snapshot/issue-25/gcloud-snapshot.sh
chmod +x gcloud-snapshot.sh
sudo mkdir -p /opt/google-compute-snapshot
sudo mv gcloud-snapshot.sh /opt/google-compute-snapshot/test-gcloud-snapshot.sh
sudo /opt/google-compute-snapshot/test-gcloud-snapshot.sh

Let me know how you get on - if it works for you, I'll add it to the main branch.

If you're interested, the issue was with how centos 6 handles UTC+- dates. I got round this by removing the +- bit from the date (-07:00) as the script doesn't use it anyway.

Cheers,
Jack

Hi Jack.

Thanks very much for your time and effort in resolving this.. It all looks good now. Awesome job, let me know if there's anything I can do for you? If you've got kids at home I developed the Safe Surfer Lifeguard device and would be happy to send you one of these: see www.safesurfer.co.nz

[root@growecewebsite tmp]# ./gcloud-snapshot.sh
2017-10-05 09:44:37: Start of Script
2017-10-05 09:44:37: Start of createSnapshotWrapper
Creating snapshot(s) gcs-growecewebsite-6778689268549088110-1507149877...
.............................................................done.
2017-10-05 09:45:34: Start of deleteSnapshotsWrapper
Deleted [https://www.googleapis.com/compute/v1/projects/fiery-orb-sss/global/snapshots/gcs-growecewebsite-6778689268549088110-1506500659].
Deleted [https://www.googleapis.com/compute/v1/projects/fiery-orb-sss/global/snapshots/gcs-growecewebsite-6778689268549088110-1506500839].
Deleted [https://www.googleapis.com/compute/v1/projects/fiery-orb-sss/global/snapshots/gcs-growecewebsite-6778689268549088110-1506537604].
2017-10-05 09:46:02: End of Script

@aaronsinclair, great news - glad to hear it's working for you.

Very kind of you to offer, but I'm fine - looks like a cool product though!

Cheers,
Jack