-
Notifications
You must be signed in to change notification settings - Fork 70
/
Copy pathexample_backup.js
28 lines (25 loc) · 962 Bytes
/
example_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
var app_key = '<app_key>';
var oauth_access_token = '<oauth_access_token>';
var organization = '<organization>';
var fs = require('fs');
var Trello = require("./main.js");
var t = new Trello(app_key, oauth_access_token);
t.get("/1/organization/" + organization + "/boards/all", function(err, data) {
if(err) throw err;
for(board in data) {
var board_id = data[board].id;
var board_name = data[board].name;
t.api('/1/board/' + board_id + '/cards/all', function(err, data) {
if(err) throw err;
var filename = board_name + " - " + new Date().toString() + ".json";
console.log('Backing up ' + data.length + ' cards for board "' + board_name);
fs.writeFile(filename, JSON.stringify(data), function(err) {
if(err) {
console.log(err);
} else {
console.log("Saved to " + filename);
}
});
});
}
});