This repository has been archived by the owner on Sep 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathkibana4-backup.js
56 lines (51 loc) · 1.67 KB
/
kibana4-backup.js
1
2
3
4
5
6
7
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
'use strict';
var _ = require('lodash');
var async = require('async');
var fs = require('fs-extra');
var debug = require('debug')('kibana4-backup');
module.exports = kibana4Backup;
/**
* options generated by commander in ./bin/kibana4-backup
*
* repo: REQUIRED - Git repo to store kibana4 data
* elasticsearchUrl: REQUIRED - Elasticsearch HTTP url you want to target
* cloneDirectory: RECOMMENDED - The directory to clone the git repo to. Should be an absolute path, must have write access.
* environment: The environment you want to target. Alphanumeric only, no whitespace.
* commitMessage: Commit message to use when changes are made.
* index: The name of the elasticsearch index you are using for kibana.
*/
function kibana4Backup(options, cb){
//Must require here due to config init step
var config = require('./lib/config')(options);
var clone = require('./lib/git/clone');
var getLatest = require('./lib/git/get-latest');
var createDirectories = require('./lib/create-directories');
var createReadmes = require('./lib/readmes/create');
var restore = require('./lib/restore');
var deploy = require('./lib/deploy');
var backup = require('./lib/backup');
var commit = require('./lib/git/commit');
var push = require('./lib/git/push');
debug('Starting kibana4 backup');
async.series([
_.partial(fs.mkdirs, config.cloneDir),
clone,
getLatest,
createDirectories,
createReadmes,
restore,
deploy,
backup,
commit,
push
], function(err, results){
if(err) {
console.error('kibana4-backup failed');
console.error(err);
return cb(err);
}
debug(results);
console.log('kibana4-backup complete');
cb();
});
}