This post describes how to take backup of your Compute Engine Instance.
There the 2 methods to take backup of your VM Instance.
- Create Image of your whole instance
- Create Snapshot of your disk
Create Image of your whole Instance
Go to Google Cloud Console and navigate to Compute Engine >> Images.
Click Create Image.
Enter a Name for your image.
In Source select Disk.
In Source Disk select the disk of the Instance.
If you select a disk of an instance which is running you need to check off the Keep instance running to take an image.
It’s not recommended to create an image from a running instance because you may get a corrupted image. So you can stop your instance and create a Image backup of your Compute Engine Instance.

Click Create.
Once a Image backup is done you can create new instance with the Image.
So taking a Image backup will result in downtime for your live website. To prevent this you can create Snapshot of your disk without any downtime.
Create a Snapshot of your Instance
Go to Google Cloud Console and navigate to Compute Engine >> Snapshots.
Click Create Snapshot.
Enter a Name for your snapshot.
In Source Disk select the disk of the Instance.

Click Create.
It will take sometime to create depending on the size of your disk. Now you can create a new VM Instance with this snapshot.
Create Backup of your Website
You can also create a backup of your program files alone as a tar.gz file.
Let’s assume you have your website files in /home/username/yourdomainname.com/public
location.
Now SSH to your VM Instance and go your respective directory to create a backup. To take a backup of the public
folder follow the below steps.
cd /home/username/yourdomainname.com
sudo tar -zcf filename.tar.gz public
This command will create a backup of the public directory.
Once the backup is done you can download the tar file to your local computer. Learn how to connect to Google Compute Engine Instance using FileZilla.
Create a Database Backup
Navigate to Storage >> CloudSQL and click the Instance you need to create backup. You can also enable automatic backups for your CloudSQL instance. To create a database backup see the below steps.
Click Export.
In Cloud Storage export location click Browse and choose your Storage bucket and enter a name for your backup.

Click Select.
In Format choose SQL.
Click Show advanced options and select the database you want to export.

Click Export.
Once the export is completed you will have your database backup in your Cloud Storage bucket.