// Module included in the following assemblies:
//
// * microshift/microshift_backup_and_restore/microshift-auto-recover-manual-backup.adoc

:_mod-docs-content-type: PROCEDURE
[id="microshift-creating-backups-auto-recovery_{context}"]
= Creating backups using the auto-recovery feature

[role="_abstract"]
To create backups for {product-title} automatic recovery, you can run `microshift backup --auto-recovery` with a directory path. The command then stores each backup in that directory so that the latest is available when you restore.

[NOTE]
====
Creating backups requires stopping {microshift-short}. You must decide on the best time to stop {microshift-short}.
====

.Prerequisites

* You stopped {microshift-short}.

.Procedure

* Create and store backups in the directory you choose by running the following command:
+
[source,terminal,subs="+quotes"]
----
$ sudo microshift backup --auto-recovery _<path_of_directory>_
----
+
** For `_<path_of_directory>_`, specify the path of the directory that stores backups. For example, `/var/lib/microshift-auto-recovery`.
+
[NOTE]
====
The `--auto-recovery` option modifies the interpretation of the `PATH` argument from the final backup path to a directory that holds all of the backups for automated recovery.
====
+
.Example output
[source,terminal]
----
??? I1104 09:18:52.100725    8906 system.go:58] "OSTree deployments" deployments=[{"id":"default-b3442053c9ce69310cd54140d8d592234c5306e4c5132de6efe615f79c84300a.1","booted":true,"staged":false,"pinned":false},{"id":"default-a129624b9233fa54fe3574f1aa211bc2d85e1052b52245fe7d83f10c2f6d28e3.0","booted":false,"staged":false,"pinned":false}]
??? I1104 09:18:52.100895    8906 data_manager.go:83] "Copying data to backup directory" storage="/var/lib/microshift-auto-recovery" name="20241104091852_default-b3442053c9ce69310cd54140d8d592234c5306e4c5132de6efe615f79c84300a.1" data="/var/lib/microshift"
??? I1104 09:18:52.102296    8906 disk_space.go:33] Calculated size of "/var/lib/microshift": 261M - increasing by 10% for safety: 287M
??? I1104 09:18:52.102321    8906 disk_space.go:44] Calculated available disk space for "/var/lib/microshift-auto-recovery": 1658M
??? I1104 09:18:52.105700    8906 atomic_dir_copy.go:66] "Made an intermediate copy" cmd="/bin/cp --verbose --recursive --preserve --reflink=auto /var/lib/microshift /var/lib/microshift-auto-recovery/20241104091852_default-b3442053c9ce69310cd54140d8d592234c5306e4c5132de6efe615f79c84300a.1.tmp.99142"
??? I1104 09:18:52.105732    8906 atomic_dir_copy.go:115] "Renamed to final destination" src="/var/lib/microshift-auto-recovery/20241104091852_default-b3442053c9ce69310cd54140d8d592234c5306e4c5132de6efe615f79c84300a.1.tmp.99142" dest="/var/lib/microshift-auto-recovery/20241104091852_default-b3442053c9ce69310cd54140d8d592234c5306e4c5132de6efe615f79c84300a.1"
??? I1104 09:18:52.105749    8906 data_manager.go:120] "Copied data to backup directory" backup="/var/lib/microshift-auto-recovery/20241104091852_default-b3442053c9ce69310cd54140d8d592234c5306e4c5132de6efe615f79c84300a.1" data="/var/lib/microshift"
/var/lib/microshift-auto-recovery/20241104091852_default-b3442053c9ce69310cd54140d8d592234c5306e4c5132de6efe615f79c84300a.1
----

.Verification

* Verify that the backup you created exists in your customized storage directory by running the following command:
+
[source,terminal,subs="+quotes"]
----
$ sudo ls -la _<path_of_directory>_
----
+
** For `_<path_of_directory>_`, specify the path of the directory that stores backups. For example, `/var/lib/microshift-auto-recovery`.
