Thursday 15 December 2011

How to schedule daily back of TestLink ( Test Management Tool )

We use Test Link Test Management Tool for all our Test cases management, Assignment of testcases and see the status of testing of any project.

Once the PC had crashed on which the server was running. Luckily it was some hardware problem and we were able to recover everything.  It made us think of taking daily backups, in case if something happens again.

Human nature is really very funny, we live like we are going to be here on Earth for long and we do everything , once somebody dies the realities  comes to our mind but stays there for one or two days and again we are back to normal "immortal" thinking.

Well this small piece of philosophy is because we never thought of taking backups until it was required.

So we started taking backup daily by writing a small piece of code :

1) Create backup.bat file 
Save below code in backup.bat file

REM [at] echo off

for /f "tokens=1" %%i in ('date /t') do set DATE_DOW=%%i

for /f "tokens=2" %%i in ('date /t') do set DATE_DAY=%%i
for /f %%i in ('echo %date_day:/=-%') do set DATE_DAY=%%i
for /f %%i in ('time /t') do set DATE_TIME=%%i
for /f %%i in ('echo %date_time::=-%') do set DATE_TIME=%%i

"C:\xampp\mysql\bin\mysqldump" --user=urusername --password=urpassword --databases databasename > "%DATE_DAY%_%DATE_TIME%_backupTestLink.sql"

save this file in "C:\xampp\mysql\backup\daily-backup\" Folder . "daily-backup" Folder is created by me to store these backups.

2) Start window scheduler to run this file at specific time.
               Go to -> Start-> Setting->Control Panel->scheduled Tasks-> Add scheduled Tasks-> Browse and select the file (backup.bat) , Perform this task-> Daily -> set the time-> enter username and password
and Finish.

The schedular will run at specific interval to create a backup.

3) But this still generates the backup at local PC, if something happens everything will be gone. So

Map one network folder ( another server which has shared folder ) .

Go to My computer -> Tools-> Map network drive -> give drive name ( automatically it takes the next letter. Browse the folder ( the network folder ) click finish.

Now in above script in the end put one copy command to copy the file to server folder

" copy C:\xampp\mysql\backup\daily-backup\%DATE_DAY%_%DATE_TIME%_backupTestLink.sql  Y:\TestLink-Backup "

Now the generated backup file will be present in both local as well as network server PC.

You can mail me on for any other methods/ideas.

" Keep Learning , Keep sharing "