Longhorn volumes backup and restore

For a robust storage mechanism, it is recommended that you back up the storage volumes at regular intervals. Adeptia Connect deployed through Adeptia Connect Rancher package helps you back up and restore the storage volumes by using Adeptia Connect Longhorn UI.

This section discusses the followings:

Creating recurring backup schedule

If you want to back up a volume, it is best that you create a backup task that runs at regular intervals before configuring the target volume for backup. Follow the steps given below to achieve this.

  1. Log in to the Rancher UI.

  2. Select Longhorn in the left panel, and then click Longhorn on the Overview section.

  3. On the Longhorn UI, click Recurring Job on the top menu bar.

  4. On the Recurring Job screen, click Create Recurring Job.

  5. On the Create Recurring Job screen, do the followings:

    1. In the Name field, provide name for the Recurring Job.

    2. In the Task field, select Backup.

    3. In the Retain field, enter the number of replicas you want to create for the backup in Amazon S3.

    4. In the Concurrency field, define how many concurrent instances of the backup can run simultaneously.

    5. In the Cron field, define the frequency (using cron expression) at which the backup instance runs.

    6. Click Ok.

Configuring the volume for backup

Once you have created the Recurring Job, you can follow the steps given below to make a volume ready for backup.

  1. Create a secret using the following Amazon S3 credentials:

    1. AWS_ACCESS_KEY_ID

    2. AWS_SECRET_ACCESS_KEY

  2. Select Longhorn in the left panel, and then click Longhorn on Overview section.

  3. On the Longhorn UI, go to Settings (on the top menu bar) > General.

  4. On the General screen, do the followings:

    1. In the Backup Target field, enter the Amazon S3 endpoint in the following format:
      s3://<Amazon S3_bucket_name>@<AWS_region>/

    2. In the Backup Target Credential Secret field, enter the name of the Amazon S3 secret created in step 1.

  5. Click Volume on the top menu bar.

  6. On the Volume screen, select the volume that you want to back up.

  7. Click Create Backup.

    You can view the details related to the configured backup by clicking Backup on the top menu bar.

Restoring the backup

Follow the steps given below to restore a volume using a backup.

  1. Scale down all the pods that use the volume to be restored.

  2. Log in to the Rancher UI.

  3. Select Longhorn in the left panel, and then click Longhorn on Overview section.

  4. On the Longhorn UI, click Volume on the top menu bar.

  5. On the Volume screen, select the volume that you restore from the backup, and then click Delete.

  6.  Click Backup on the top menu bar.

  7. Select the backup that you want to restore, and then click Restore Latest Backup.

  8. In the Restore Backup window, do the followings:

    1. In the Name field, provide a name for the volume to be restored.
      Ensure that the volume name you provide is the same as that of the backup that you are going to restore.

    2. In the Number of Replicas field, enter the number of replicas you want to create for the restored volume.

    3. In the Access Mode field, select either of the two options based on your requirement.

      • ReadWriteOnce

      • ReadWriteMany

    4. Click Ok.

  9. Click Volume on the top menu bar.
    The restored volume can be seen in Detached state. To attach it to the nodes, do the followings:

    1. On the Volume screen, go to the dropdown menu against the restored volume, and then click Create PV/PVC.

    2. On the Create PV/PVC screen, verify the details, and then click OK.

    3. Scale up the pods that are going to use the restored volume.