Puppet Plan: complyadm::backup
- Defined in:
- plans/backup.pp
Summary
Backup the database and volumes.Overview
Use this plan to back up the Security Compliance Management database and Docker volumes to a ZIP archive. When you run the plan, the location of the backup is returned. You can see of list of these backups using complyadm::list_backups and restore one using complyadm::restore.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'plans/backup.pp', line 8
plan complyadm::backup() {
run_plan('complyadm::check_bolt_version')
$config = complyadm::config()
# Run the validate plan to ensure the target is in good shape before backing up
$validate_output = run_plan('complyadm::validate')
if($validate_output['failed'].length() > 0) {
fail_plan('Target failed validation. Re-run the install plan to correct the installation before running a backup.')
}
$db_role = $config['roles']['database']['services']['comply_postgres']
$database_info = Complyadm::Support_bundle::Database_info.new({
'container_name' => $db_role['container']['name'],
'database_user' => $db_role['admin_db_username'],
})
$roles = $config['roles']
$volumes = [
{
'container' => $roles['backend']['services']['comply_scarpy']['container']['name'],
'name' => 'benchmarks',
},
{
'container' => $roles['backend']['services']['comply_redis']['container']['name'],
'name' => 'redis',
},
]
$host = $config['roles']['backend']['targets'][0]
$result = run_task(
'complyadm::backup',
# TODO: Currently only supports a single target
$host,
{
'runtime' => $config['runtime'],
'backup_dir' => $config['backup_dir'],
'database_info' => $database_info,
'volumes' => $volumes,
'image' => $config['images']['comply_postgres'],
'version' => complyadm::module_version(),
'_run_as' => 'root',
'_catch_errors' => true,
}
)
if($result[0].ok) {
$archive = $result[0].value['backup_archive']
$error_message = @("SUCCESS")
Backup complete. The resulting file is ${archive} on ${$host}
Make sure this file is on distributed storage or backed up to an external location for safety.
| SUCCESS
out::message($error_message)
} else {
$error_message = @("ERROR")
Backup failed:
${result[0].value['message']}
${result[0].value['error']}
Check the bolt-debug.log for additional details.
| ERROR
out::message($error_message)
}
}
|