Ever wanted to store all the discussion on your github repositories for viewing offline or for backup ?
If yes, this is the tool for you !
This command fetches the issues and comments from your github repository and stores it in a .txt
file for backup. It also displays it in an HTML file which looks similar to GitHub environment,
e.g. text file and html file.
PHP - Setup your PHP for commandline
Git Bash (or any Linux platform)
Note 1 - Git has cURL inbuilt, so you won't need separate cURL if you use Git.
Note 2 - If you have installed Git, your windows CMD.exe also become able to execute this program. (So, you can stick to your favourite commandline).
Demonstration video. N.B. - The video was made for version 1.0.0 which took three arguments. Version 1.1.0 takes five arguments as explained below. The essense remains the same.
github_issue_backup.sh UserName RepoName IssueNumber [ OutputFolder | -p ] [ -l | -f ] [ -y | -n ]
e.g. github_issue_backup.sh drdhval2785 SanskritVerb 1:10,13,15 e:/backup -l -y
to fetch the issues in the current repository. (Don't forget to change username, reponame, Issue number and Destination folder according to your need)github_issue_backup.sh UserName RepoName IssueNumber [ OutputFolder | -p ] [ -l | -f ] [ -y | -n ]
e.g. github_issue_backup.sh drdhval2785 SanskritVerb 1:10,13,15 e:/backup -l -y
-a
to fetch all the repositories.1,2,3,15,18
. You can also write ranges separated by :
e.g. 1:10,15,20
. If you want to backup all the issues write -a
to download ALL issues of the repository.-p
i.e. parent. -l
would do limited version i.e. Syntax Highlighting and Emoji support would not be there. -f
would give full support (but at the cost of 6 MB odd additional libraries being pasted in each directory).-y
would download the images and -n
would not download the images. This argument is optional. If it is not set, it would download images.github_issue_backup.sh drdhaval2785 SanskritVerb 1:10,13,15 -p -l
would fetch issues 1 to 10, 13 and 15 of drdhaval2785/SanskritVerb repository without Syntax Highlighting and Emoji, and store it in working directory.github_issue_backup.sh drdhaval2785 SanskritVerb 1:10,13,15 -p -f
would fetch issues 1 to 10, 13 and 15 of drdhaval2785/SanskritVerb repository with Syntax Highlighting and Emoji, and store it in working directory.github_issue_backup.sh drdhaval2785 SanskritVerb 1:10,13,15 e:/output -l
would fetch issues 1 to 10, 13 and 15 of drdhaval2785/SanskritVerb repository without Syntax Highlighting and Emoji, and store it in e:/output directory.github_issue_backup.sh drdhaval2785 SanskritVerb 1:10,13,15 e:/output -f
would fetch issues 1 to 10, 13 and 15 of drdhaval2785/SanskritVerb repository with Syntax Highlighting and Emoji, and store it in e:/output directory.github_issue_backup.sh drdhaval2785 SanskritVerb -a e:/output -l
would fetch all issues of drdhaval2785/SanskritVerb repository without Syntax Highlighting and Emoji, and store it in e:/output directory.github_issue_backup.sh drdhaval2785 SanskritVerb -a e:/output -f
would fetch all issues of drdhaval2785/SanskritVerb repository with Syntax Highlighting and Emoji, and store it in e:/output directory.github_issue_backup.sh drdhaval2785 -a -a e:/output -l
would fetch all issues of all repositories of user drdhaval2785 without Syntax Highlighting and Emoji, and store it in e:/output directory.github_issue_backup.sh drdhaval2785 -a -a e:/output -f
would fetch all issues of all repositories of user drdhaval2785 with Syntax Highlighting and Emoji, and store it in e:/output directory.github_issue_backup.sh drdhaval2785 -a -a -p -l
would fetch all issues of all repositories of user drdhaval2785 without Syntax Highlighting and Emoji, and store it in working directory.github_issue_backup.sh drdhaval2785 -a -a -p -f
would fetch all issues of all repositories of user drdhaval2785 with Syntax Highlighting and Emoji, and store it in working directory.To fetch the data of all issues of all repositories of any given user / organization, option 10 is the safest one to work with (though a bit costly on space).
In any of the above examples let's say 10th example, if the user doesn't want to download the images (to decrease backup size) he can add -n
at the end like github_issue_backup.sh drdhaval2785 -a -a -p -f -n
.
There are two lines in cURL which need a bit of explanation:
curl 'https://api.github.com/repos/'$1/$2'/issues/'$a'?state=all&page=1&per_page=1000&client_id=1dd1dddcb68d6148c249&client_secret=7577e3bd5cb5ad20bea86430a8ed5a29df5fa455' > $1/$2/$a.txt
An explanation of the arguments passed in this cURL line is in order.
state=all fetches all the issues (Available options are open/closed/all).
page=1
means the first page of the output.
per_page=1000
would mean the the output would have 1000 entries maximum. If your issue has more than 1000 comments, this can be increased to suitable number.
>$1/$2/$a.txt
writes the data fetched by curl to the file which is numbered as per issue number e.g. drdhaval2785/SanskritVerb/1.txt
curl 'https://api.github.com/repos/'$1/$2'/issues/'$a'/comments?state=all&page=1&per_page=1000&client_id=1dd1dddcb68d6148c249&client_secret=7577e3bd5cb5ad20bea86430a8ed5a29df5fa455' >> $1/$2/$a.txt
>>$1/$2/$a.txt
appends the data fetched by cURL to the file which is numbered as per issue number e.g. drdhaval2785/SanskritVerb/1.txt