Making Exact Copy of Server Google Cloud - google-cloud-platform

I have recently started using Google Cloud over Digital Ocean because they are now offering a free trial. Although I am having an issue with figuring out how to make an exact copy of a server.
On Digital ocean, I can create an exact copy of a server as a new server, this will copy over all installd files and configurations to the new server. But all I have been able to find on GCP is a way to create a similar instance, but this only copies the settings of the ubuntu image. Is there a way to make an exact copy of a server on Google Cloud Platform? Thank you in advance!

You have two options:
a. Using persistent disk snapshots
b. Using machine image(Beta)
The same point of those methods is create some "Image" from your original server, and create new instance from the "Image".
The difference between (a.) and (b.) is, the scope of backup.
(a.) is only about a disk.
(b.) contains all the configuration, metadata, permissions, and data from one or more disks for a VM instance running on Compute Engine.
Please refer the official documents below.
Reference
Persistent Disk Snapshots
https://cloud.google.com/compute/docs/disks/create-snapshots
Machine Images
https://cloud.google.com/compute/docs/machine-images

Related

How to Deploy a docker container with volume in Cloud Run

I am trying to publish an application I wrote in .NET Core with docker and a mounted volume. I can't really figure out or see any clear solution to my issue that will be cheap (Its for a university project.)
I tried running a docker-compose via a cloudbuild.yml linked in this post with no luck, also tried to put my dbfile in a firebase project and tried to access it via the program but it didn't work. I also read in the GCP documentation that i can probably use Filestore but the pricing is way out of budget for me. I need to publish an SQLite so my server can work correctly, that's it.
Any help would be really apreciated!
Basically, you can't mount volume in Cloud Run. It's a stateless environment and you can't persist data on it. You have to use external storage to persist your data. See the runtime contract
WIth the 2nd execution runtime environment, you can now mount Cloud Storage bucket with GCSFuse, and Filestore path with NFS

Why "activate cloud shell" opens a shell that is not what is under my newly created "Instance-1" virtual machine?

I just set up everything on google cloud shell (terminal that activates when you press "activate cloud shell" on top right). However, i just now realised it is not the same thing as the Instance-1 i created as connecting to it by pressing "SSH" leaves me with none of the software i installed in google cloud shell.
Why is it so? Is it possible to add google cloud shell to the Instance-1 virtual machine i just created? (it would greatly easy software setup)
As #John hanley expressed in the comments, cloud shell are transient and it isn't suggested to utilize it to store or introduce lasting data and applications.
In your case, you'd like to have an instance where you've got a default setup with the fundamental software preinstalled. There are 3 alternatives you'll utilize for this situation.
Using Snapshot, Image or Instance template.
A snapshot reflects the contents of a persistent disk in a concrete
instant in time. An image is the same thing, but includes an
operating system and boot loader and can be used to boot an instance.
But snapshot is cheaper in terms of cost.
Images are primarily meant for boot disk creation. They optimized for
multiple downloads of the same data over and over. If the same image
is downloaded many times, subsequent to the first download the following
downloads are going to be very fast (even for large images).
Instance templates define the machine type, boot disk image or
container image, labels, and other instance properties. An instance
template is a global resource that is not bound to a zone or a region.
All these options can create an instance using the cloud shell and you can get the command line version by clicking the Equivalent command line button when creating the resource.
After the setup, you will just initiate the command on cloud shell based on the option you chose then connect to your instance via SSH from cloud shell as also suggested by #dany L.

GCP - moving VMs across projects with the Google Cloud SDK

I want to move some VMs across projects on GCP using the Cloud SDK.
I'd like the process on a high level, and then possibly also some links out to the relevant docs, although I can RTFM when I know what the general high-level steps are.
I think what I want to do is
Create a snapshot
Save it somewhere
Create two Cloud SDK contexts?
Prepare a destination in the context for the new project
Copy the snapshots over to the new context and its associated storage
Rehydrate from the copied snapshot in the new project once everything is copied.
Please help. I'm new with this stuff and want to know whether this is really how it should be done.
Thanks!
You can use this guide
Quick summary of steps needed
Detach the boot disk from the VM that you intend to move by deselecting “Delete boot disk on instance delete” and terminating the VM
Create an image from the detached boot disk
Upload the image to Google Cloud Storage and share it with the new project
Create a custom image under the new project based on the image you uploaded to Google Cloud Storage
Create a new VM instance under the new project based on the custom image

Google cloud: How to set up VM and spin off instances

I am new to google cloud and want to make sure I start off correctly - so apologies for the naive questions! I have been trying to look up the documentation, but it seems a bit over-whelming at the moment!
With SGE, I store my data on a drive, install software in my local directory and spin off cores/cpus with the gsub command. In gcloud, so far I have:
Stored my data in a bucket.
Created a VM and install software on this
My questions:
How do I save the VM image so that I don’t have to install the software for each new instance of VM?
How/what script do I write to spin off 10 VMs(?) so that each VM gets a different chunk of the data I have in my bucket?
Or am I thinking of this incorrectly? Should I be approaching this differently? Any specific documentation pages that would help me?
Sorry, completely new to the cloud and want to make sure I do things correctly.
thanks for all help and suggestions!
You need to create a managed instance group. A managed instance group contains identical VMs. In order to create a managed instance group you have to create an Instance Template and then use it to create VMs for you group. See Creating Instance Templates for more information

How to interface an AWS hosted website with Database on EBS?

The startup I'm working for is constructing a website, and we want to use AWS to run and host our site and the accompanying mysql database. Apparently when you terminate an AWS instance, any data stored on it is lost, so we would be keeping the database on the EBS system. The thing I can't figure out, though, is how to interface things running on these two different platforms. How do I tell the web server where the database is?
Sorry if this is a really noob question. Still trying to grasp how this whole cloud service works.
If I am reading correct, your DB is on the EBS mounted on the same machine, if that is the case, you have to make sure you tell MySQL (my.cnf) to point it's datadir to EBS directory.
Rest is as usual. Your host is localhost and your user credentials.
BTW, FYI, there is one more option from Amazon for DB that is RDS (http://aws.amazon.com/rds/) which provides lots of functionality + advantages, take a look at it.