Backup and restore


Red Hat build of MicroShift 4.17

Backup and restore the Red Hat build of MicroShift database

Red Hat OpenShift Documentation Team

Abstract

Learn how to backup and restore the Red Hat build of MicroShift database.

Chapter 1. Backing up and restoring MicroShift data

You can manually back up and restore the MicroShift database on all supported systems. Greenboot health checks must be completed and you must stop the MicroShift service prior to any backups.

Note

Only MicroShift data is backed up with the following procedures. Application data is not included.

  • On rpm-ostree systems, MicroShift automatically creates a backup on every start. These automatic backups are deleted and replaced with the latest backup each time the system restarts.
  • If you are using an rpm-ostree system, the data is automatically restored after Greenboot rolls the system back. This data restoration ensures that the database matches the software running on the host after the rollback is completed.
  • On other system types, you must back up and restore data manually.

1.1. Stopping the MicroShift service

Use the following procedure to stop the MicroShift service.

Prerequisites

  • The MicroShift service is running.

Procedure

  1. Enter the following command to stop the MicroShift service:

    $ sudo systemctl stop microshift
  2. Workloads deployed on MicroShift might continue running even after the MicroShift service has been stopped. Enter the following command to display running workloads:

    $ sudo crictl ps -a
  3. Enter the following commands to stop the deployed workloads:

    $ sudo systemctl stop kubepods.slice

1.2. Backing up MicroShift data manually

You can back up MicroShift data manually at any time. Back up your data before system updates to preserve it for use if an update fails or for other system trouble. Automated backups are created in the /var/lib/microshift-backups directory. You can use this directory for manually backing up and restoring data by specifying it in each command. When you create a backup, you must use the entire file path for the output file.

Prerequisites

  • You have root access to the host.
  • MicroShift is stopped.

Procedure

  1. Manually create a backup by using the parent directory and specifying a name, such as /var/lib/microshift-backups/<my_manual_backup>, by running the following command:

    $ sudo microshift backup /var/lib/microshift-backups/<my_manual_backup>

    Replace <my_manual_backup> with the backup name that you want to use.

    Example output

    ??? I1017 07:38:16.770506    5900 data_manager.go:92] "Copying data to backup directory" storage="/var/lib/microshift-backups" name="test" data="/var/lib/microshift"
    ??? I1017 07:38:16.770713    5900 data_manager.go:227] "Starting copy" cmd="/bin/cp --verbose --recursive --preserve --reflink=auto /var/lib/microshift /var/lib/microshift-backups/test"
    ??? I1017 07:38:16.776162    5900 data_manager.go:241] "Finished copy" cmd="/bin/cp --verbose --recursive --preserve --reflink=auto /var/lib/microshift /var/lib/microshift-backups/test"
    ??? I1017 07:38:16.776256    5900 data_manager.go:125] "Copied data to backup directory" backup="/var/lib/microshift-backups/test" data="/var/lib/microshift"

  2. Optional: Manually create a backup in a specific parent directory with a custom name by running the following command:

    $ sudo microshift backup /mnt/<other_backups_location>/<another_manual_backup>

    Replace <other_backups_location> with the directory you want to use and <my_manual_backup> with the backup name you want to use.

Verification

  • You can verify that the backup exists by viewing the data in the directory you chose. For example, /var/lib/microshift-backups/<my_manual_backup>/ or /mnt/<other_backups_location>/<another_manual_backup>.

1.3. Restoring MicroShift data backups manually

You can restore MicroShift data from a backup manually. Backups can be restored after updates, or after other system events that remove or damage required data. Automated backups are in the /var/lib/microshift-backups directory by default. You can use this directory for manually backing up and restoring data by specifying it in each command. When you restore a backup, you must use the entire file path.

Note

On an rpm-ostree system, MicroShift backs up and restores data automatically.

Prerequisites

  • Root access to the host.
  • Full path of the data backup file.
  • The MicroShift service is stopped.

Procedure

  1. Manually restore MicroShift data by using the full file path of the backup you want to restore by running the following command:

    $ sudo microshift restore /var/lib/microshift-backups/<my_manual_backup>

    Replace <my_manual_backup> with the backup name that you used. Optional: You can also restore automatic ostree backups using the full file path.

    Example output

    ??? I1017 07:39:52.055165    6007 data_manager.go:131] "Copying backup to data directory" storage="/var/lib/microshift-backups" name="test" data="/var/lib/microshift"
    ??? I1017 07:39:52.055243    6007 data_manager.go:154] "Renaming existing data dir" data="/var/lib/microshift" renamedTo="/var/lib/microshift.saved"
    ??? I1017 07:39:52.055326    6007 data_manager.go:227] "Starting copy" cmd="/bin/cp --verbose --recursive --preserve --reflink=auto /var/lib/microshift-backups/test /var/lib/microshift"
    ??? I1017 07:39:52.061363    6007 data_manager.go:241] "Finished copy" cmd="/bin/cp --verbose --recursive --preserve --reflink=auto /var/lib/microshift-backups/test /var/lib/microshift"
    ??? I1017 07:39:52.061404    6007 data_manager.go:175] "Removing temporary data directory" path="/var/lib/microshift.saved"
    ??? I1017 07:39:52.063745    6007 data_manager.go:180] "Copied backup to data directory" name="test" data="/var/lib/microshift"

  2. Optional. Manually restore data from a customized directory by using the full file path of the backup. Run the following command:

    $ sudo microshift restore /<mnt>/<other_backups_location>/<another_manual_backup>

    Replace <other_backups_location> with the directory you used and <my_manual_backup> with the backup name you used when creating the backup you are restoring.

  3. Restart the host. Restarting the host enables all workloads and pods to restart.

Verification

  • Use the oc get pods -A command to verify that the cluster is running, then check the restored data.

Legal Notice

Copyright © 2024 Red Hat, Inc.
The text of and illustrations in this document are licensed by Red Hat under a Creative Commons Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available at http://creativecommons.org/licenses/by-sa/3.0/. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must provide the URL for the original version.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, Red Hat Enterprise Linux, the Shadowman logo, the Red Hat logo, JBoss, OpenShift, Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
Java® is a registered trademark of Oracle and/or its affiliates.
XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries.
MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries.
Node.js® is an official trademark of Joyent. Red Hat is not formally related to or endorsed by the official Joyent Node.js open source or commercial project.
The OpenStack® Word Mark and OpenStack logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation's permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
All other trademarks are the property of their respective owners.
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.