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 in GCP by anonymous
• 4,120 points
13 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 by Sirajul
• 38,420 points

Related Questions In GCP

0 votes
1 answer
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 in GCP by Sirajul
• 38,420 points
97 views
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 in GCP by Sirajul
• 38,420 points
38 views
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 in GCP by Sirajul
• 38,420 points
47 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 in GCP by Sirajul
• 38,420 points
23 views