-
Language:
English
-
Language:
English
Chapter 10. Backing Up and Restoring Cartridges
OpenShift Enterprise provides
snapshot
and restore
features for user applications. These features enable OpenShift Enterprise application developers to:
- Snapshot the current state of an application to create a backup.
- Restore an application from an archived state.
- Copy or rename an application by taking a snapshot, creating a new application, then restoring the snapshot data to the new application.
10.1. Snapshot
When an application developer runs the
rhc snapshot save
command, OpenShift Enterprise creates an archive of the application and performs the following steps:
- Stops the application by running the
gear stop
command. - Runs the
control pre-snapshot
command for each cartridge on the gear. You can control cartridge serialization in the snapshot by implementing thecontrol pre-snapshot
command in conjunction with exclusions. For example, you can snapshot to a database dump instead of a database file. - Builds a list of exclusions from the
snapshot_exclusions
entry in the$cartridge_name/metadata/managed_files.yml
file for each cartridge on the gear. - Creates an archive of the application in
tar.gz
format and writes it tostdout
for use by the client tools. In addition to the files listed in thesnapshot_exclusions
entry in themanaged_files.yml
file, OpenShift Enterprise excludes the following files:- Selected gear user files:
.tmp
,.ssh
,.sandbox
. - Application state file:
app-root/runtime/.state
. - Bash history file:
$OPENSHIFT_DATA_DIR/.bash_history
.
- Runs the
control post-snapshot
command for each cartridge on the gear. Use this script to cleanup after the snapshot runs. - Will either stop or start the gear based on the state of the application before the snapshot.
Snapshot Exclusions
Use the optional snapshot_exclusions
entry in the $cartridge_name/metadata/managed_files.yml
file to list files to exclude from the snapshot and restore process. File patterns originate from the OPENSHIFT_HOMEDIR
directory, not the cartridge directory. Do not exclude files that your cartridge requires to operate.
Example 10.1. snapshot_exclusions Entry
snapshot_exclusions: - mydir/*
OpenShift Enterprise uses the
tar
command when performing snapshots. See the tar
man page --exclude-from
option for more information.