Created
January 4, 2013 04:34
-
-
Save zph/4449950 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'open-uri' | |
# Script to export json data from Trello | |
# Written by ZPH <zander@civet.ws> | |
# Credit for API call belongs to http://www.shesek.info/general/automatically-backup-trello-lists-cards-and-other-data | |
# | |
# Caveats: | |
# -API limits the number certain parameters returned. | |
# -JSON output may be truncated for large boards; further research needed. | |
# Variables to set as Environmental Variables or directly in script | |
# PUBLIC_KEY='32CHARACTERPUBLICKEY' | |
# ACCESS_TOKEN_KEY='65CHARACTERAPPLICATIONTOKEN' | |
# Board hashes can be found in URL of board or by using script in Trello-Archiver | |
PUBLIC_KEY = ENV['TRELLO_PUBKEY'] | |
ACCESS_TOKEN_KEY = ENV[ 'TRELLO_APP_TOKEN' ] | |
HASH_OF_BOARD_HASHES = %w[ EXAMPLEBOARDHASH1 EXAMPLEBOARDHASH2 ETC ] # must be space delimited | |
# Beginning of script | |
# ========= | |
# Do not change below this line | |
HASH_OF_BOARD_HASHES.each do |board_hash| | |
puts board_hash | |
url = "https://api.trello.com/1/boards/#{board_hash}?actions=all&actions_limit=1000&cards=all&lists=all&members=all&member_fields=all&checklists=all&fields=all&key=#{PUBLIC_KEY}&token=#{ACCESS_TOKEN_KEY}" | |
response = open(url).read | |
output_filename = "#{Time.now.strftime('%Y%m%d%H%M%S')}_#{board_hash}.json" | |
case response | |
when "invalid id" | |
puts "=========================================" | |
puts "=========================================" | |
puts "#{board_hash} FAILED!" | |
puts "=========================================" | |
puts "=========================================" | |
;; | |
else | |
File.write(output_filename, response) | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment