Learning paths / Operate your application / Backups and availability

Lab: back up and restore

Verified lab · 25 min · Module 8, lesson 4 of 530 min left in this module

Module 8 · Backups and availabilityLesson 4 of 5

Self-checked for now. Automatic checking arrives with sign-in; until then, tick off each item under Check your work yourself.

Goal: Copy a file off a SphereFiles volume, change the data, copy the file back, and read the first value back.

You need notes Running with the notes-data volume mounted at /data, from lab 5.5.4, and csph pointed at your lab environment (csph context).

Haven't done lab 5.5.4?

Do it first: it deploys the notes app, creates the volume and mounts it. The notes app keeps one note in /data/note.txt: POST /note saves the request body, GET /note returns it. Because the whole volume is mounted at /data, that file is note.txt at the top of the volume.

SphereFiles doesn't take restore points, so the copy that saves you is one you made. This lab makes one with csph files cp, breaks the data, and puts the copy back.

  1. Save the value to keep

    curl -X POST --data "before backup" https://<your-notes-url>/note
    curl https://<your-notes-url>/note
    

    You should seeNo error from curl, and the second command prints your note.

  2. Find the volume

    csph volumes ls
    

    You should seenotes-data in the list.

  3. Copy the file off the volume

    csph files cp notes-data:/note.txt ./note-backup.txt
    cat note-backup.txt
    

    The volume side is written <volume>:<path>. This copy lives on your machine now, outside ComputeSphere.

    You should seebefore backup, printed from your copy.

  4. Change the data

    curl -X POST --data "after backup" https://<your-notes-url>/note
    curl https://<your-notes-url>/note
    

    This is the mistake you're about to undo.

    Check yourself

    If you copied note-backup.txt back an hour from now, what would happen to notes saved in that hour?

    You should seeafter backup

  5. Copy the file back

    csph files cp ./note-backup.txt notes-data:/note.txt
    

    There's no redeploy: notes reads the file on every request, and every spherelet sees the new copy.

    You should seeNo error from csph.

  6. Read the first value back

    curl https://<your-notes-url>/note
    

    You should seebefore backup

Check your work

  • If this doesn't pass

    Open notes-data under Storage management and check its Mounts.

  • If this doesn't pass

    Still after backup? Check the copy-back named notes-data:/note.txt, not a new path. If csph says no environment is selected, run csph context.

In the docs