Backup a RAM disk before instance starts on GCP

0 votes
How can I back up a RAM disk before my instance starts up again?
Oct 18, 2019 in GCP by anonymous
• 6,260 points
575 views

1 answer to this question.

0 votes

You can back up a RAM disk before your instance restarts to preserve the RAM disk data until the instance starts up again. Back up your data to a persistent disk to preserve it.

  1. Create and mount a persistent disk to use as a backup disk for your RAM disk. Make sure the disk is big enough to contain the information in the RAM disk.

  2. Create a shutdown script for your instance with an rsync command that writes the RAM disk contents to the backup volume. For this example, use the gcloud tool to add the shutdown-script metadata to the instance with the RAM disk mounted at /mnt/ram-disk and the persistent disk mounted at /mnt/ram-disk-backup.

    gcloud compute instances add-metadata example-instance --metadata shutdown-script="#! /bin/bash
    rsync -a --delete --recursive --force /mnt/ram-disk/ /mnt/ram-disk-backup/
    EOF"
  3. Optionally, you can also create a startup script that restores the files back to the RAM disk when the instance starts again. Use the gcloud tool to add the startup-script metadata to the instance.

    gcloud compute instances add-metadata example-instance --metadata startup-script="#! /bin/bash
    rsync -a --recursive --force /mnt/ram-disk-backup/ /mnt/ram-disk/
    EOF"
answered Oct 18, 2019 by Sirajul
• 59,230 points

Related Questions In GCP

0 votes
1 answer

How to add a regional persistent disk to a VM instance on GCP?

You must first create the regional persistent ...READ MORE

answered Oct 18, 2019 in GCP by Sirajul
• 59,230 points
2,727 views
0 votes
1 answer
0 votes
1 answer

Creating password for a windows instance on GCP

Windows Server instances use password authentication instead ...READ MORE

answered Sep 24, 2019 in GCP by Sirajul
• 59,230 points
4,329 views
0 votes
1 answer
0 votes
1 answer

Creating a SQL Server instance using Google Compute engine.

Google Compute Engine provides public images preconfigured with ...READ MORE

answered Sep 23, 2019 in GCP by Sirajul
• 59,230 points
2,896 views
0 votes
1 answer
0 votes
1 answer

How do i install gcloud compute?

The gcloud compute command-line tool enables you to easily ...READ MORE

answered Sep 23, 2019 in GCP by Sirajul
• 59,230 points

edited Jun 16, 2023 by Khan Sarfaraz 1,244 views
0 votes
1 answer

How do i delete a RAM disk from my instance on GCP?

You can unmount a tmpfs RAM disk just like ...READ MORE

answered Oct 22, 2019 in GCP by Sirajul
• 59,230 points
1,025 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP