drdhaval2785 / github_issue_backup

a script to backup github issues
0 stars 0 forks source link

Cron option #22

Closed drdhaval2785 closed 9 years ago

drdhaval2785 commented 9 years ago

It would be great if the issues can be backed up on their own on weekly basis / daily / fortnightly / monthly basis.

drdhaval2785 commented 9 years ago

Right now created cronjob.sh file (single click) to backup sanskrit-lexicon/CORRECTIONS repository. Still looking for time based cron script.

drdhaval2785 commented 9 years ago

Added a sheduled execution every week at sunday via Task Scheduler

http://stackoverflow.com/questions/7195503/setting-up-a-cron-job-in-windows

gasyoun commented 9 years ago

So I guess the feature list is full by now.

funderburkjim commented 9 years ago

One feature I thought of, was to make, for each repository, an 'index.html' file, which would show, for each issue, the issue number, issue title, and a link to the local issue html.

One way to write this would be as a php function which reads all the nn.txt files for the repository, and writes html/index.html.

drdhaval2785 commented 9 years ago

The windows task scheduler launches the .bat / .sh file, but gives no output. Will have to examine this again.

funderburkjim commented 9 years ago

It might be that the shell scripts need to be run 'under' gitbash.

From stackoverflow, you can launch gitbash from within 'cmd.exe'.

Test setup

Here's a test.sh (it uses curl, which cmd.exe does not know about, but gitbash does)

curl --version
curl   -o testout1.txt https://www.wikipedia.org
echo "sleeping for 5 seconds"   # sleep, so we can see the (temporary) cmd window in first test below
sleep 5

And, here is a batch file dotest.bat

"C:\Program Files (x86)\Git\bin\sh.exe" --login basic\test.sh

# Note: the '--login' seems to be necessary

In this example, test.sh is in a subdirectory 'basic' of the directory where dotest.bat resides.

test1:

double-click dotest.bat This generates in testout1.txt the wikipedia html page. SUCCESS

test2:

delete testout1.txt, in a cmd.exe shell, dotest

SUCCESS

test3

copy test.sh to test.bat, and try running it in a cmd.exe Doesn't work -- curl and sleep not recognized

conclusion

Maybe change 'cronjob_sanskrit_lexicon.bat' to

"C:\Program Files (x86)\Git\bin\sh.exe" --login cronjob_sanskrit_lexicon.sh

This might work.

drdhaval2785 commented 9 years ago

Thanks for the hint @funderburkjim.

I tried it that way, but didn't succeed.

This finally worked for me. cronjob_sanskrit_lexicon.sh has the following entry now.

cd E:/C_drive/xampp/htdocs/github_issue_backup
sh github_issue_backup.sh sanskrit-lexicon -a -a e:/backuptrial -l -y
sh github_issue_backup.sh drdhaval2785 -a -a e:/backuptrial -l -y
sh github_issue_backup.sh funderburkjim -a -a e:/backuptrial -l -y
sh github_issue_backup.sh gasyoun -a -a e:/backuptrial -l -y
sleep 120

Please note that the earlier script missed this cd. Therefore, it is quite possible that the bash never reached our scripts. Even after cding to the proper place, the script said that github_issue_backup.sh command not found. So, I added sh before it to make sure that the computer understands that this is a shell script. After these two changes, it has started working well.

The task scheduler is set like this

Program script "C:\Program Files (x86)\Git\bin\sh.exe" Arguments --login -i E:/C_drive/xampp/htdocs/github_issue_backup/cronjob_sanskrit_lexicon.sh i.e. --login -i pathtodirectory/cronjob_sanskrit_lexicon.sh

capture

N.B. - Please note that I have added -i to the script. That is because the properties of git bash says that the proper target to open git bash is the one shown above.

capture

drdhaval2785 commented 9 years ago

Right now the code is backing it up at set up backup folder. What remains to be done is to zip and give timestamp to show that this is the backup of a specific date and time.

funderburkjim commented 9 years ago

Just a note to say that I've set up a Windows task-scheduler job, and that it works!.

Followed the instructions above, with minor alterations for my machine.

# Note use of 'forward slash' in the file paths of first 2 lines:
cd C:/ejf/pdfs/TM2013/0github_bkup/github_issue_backup-master
DIROUT=C:/ejf/pdfs/TM2013/0github_bkup/bkup
sh github_issue_backup.sh sanskrit-lexicon -a -a $DIROUT -l -y
sh github_issue_backup.sh drdhaval2785 -a -a $DIROUT -l -y
sh github_issue_backup.sh funderburkjim -a -a $DIROUT -l -y
sh github_issue_backup.sh gasyoun -a -a $DIROUT -l -y
sleep 120
        --login C:/ejf/pdfs/TM2013/0github_bkup/github_issue_backup-master/ejfbkup.sh

The output looks good. The index.html files are good additions.

@drdhaval2785 Thanks again for setting up this system.