Backup and restore
Backup and restore the Red Hat build of MicroShift database
Abstract
Chapter 1. Backing up and restoring MicroShift data Copy linkLink copied to clipboard!
To back up and restore MicroShift data manually, you can use the backup and restore procedures for the database on all supported systems. For application data, you must define your own backup and restore steps.
Only MicroShift data is backed up with the following procedures. Application data is not included.
-
On
rpm-ostreesystems, 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-ostreesystem, 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 Copy linkLink copied to clipboard!
To stop the MicroShift service, you can run systemctl stop microshift. You can also stop any deployed workloads by running systemctl stop kubepods.slice.
Prerequisites
- The MicroShift service is running.
Procedure
Enter the following command to stop the MicroShift service:
sudo systemctl stop microshift
$ sudo systemctl stop microshiftCopy to Clipboard Copied! Toggle word wrap Toggle overflow 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
$ sudo crictl ps -aCopy to Clipboard Copied! Toggle word wrap Toggle overflow Enter the following commands to stop the deployed workloads:
sudo systemctl stop kubepods.slice
$ sudo systemctl stop kubepods.sliceCopy to Clipboard Copied! Toggle word wrap Toggle overflow
1.2. Backing up MicroShift data manually Copy linkLink copied to clipboard!
To back up Red Hat build of MicroShift data manually, you can run microshift backup with a full path to the backup location. Stop the service first and use the entire path for the output file or directory.
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. You can use the /var/lib/microshift-backups for manually backing up and restoring data by specifying it in each command.
Prerequisites
- You have root access to the host.
- MicroShift is stopped.
Procedure
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>
$ sudo microshift backup /var/lib/microshift-backups/<my_manual_backup>Copy to Clipboard Copied! Toggle word wrap Toggle overflow For
<manual_backup>, specify 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"
??? 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"Copy to Clipboard Copied! Toggle word wrap Toggle overflow
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>
$ sudo microshift backup /mnt/<other_backups_location>/<another_manual_backup>Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
For
<other_backups_location>, specify the directory that you want to use. -
For
<another_manual_backup>, specify the backup name that you want to use.
-
For
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 Copy linkLink copied to clipboard!
To restore Red Hat build of MicroShift data after an update or data loss, you can run microshift restore with the full path to the backup. Backups can be restored after updates, or after other system events that remove or damage required data. When you restore a backup, you must use the entire file path.
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
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>
$ sudo microshift restore /var/lib/microshift-backups/<my_manual_backup>Copy to Clipboard Copied! Toggle word wrap Toggle overflow For
<my_manual_backup>, specify the backup name that you want to use. Optionally, you can also restore automaticostreebackups using the full file path.Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
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>
$ sudo microshift restore /<mnt>/<other_backups_location>/<another_manual_backup>Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
For
<other_backups_location>, specify the directory that you used. -
For
<another_manual_backup>, specify the backup name that you used.
-
For
- Restart the host. Restarting the host enables all workloads and pods to restart.
Verification
Use the
oc get pods -Acommand to verify that the node is running, then check the restored data.oc get pods -A
$ oc get pods -ACopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThis example output shows a basic MicroShift installation. If you installed optional RPMs, the status of pods running those services is also expected in your output.