Mysql backup and delete older files

We were taking mysql backups using a very simple shell script which was using mysqldump as below.

#!/bin/sh
#echo "Starting the script";
HOST=localhost
USER=myDBUser
PASSWD='myPassword';

# create directory if it doesn't exist
OLDBACKUP=/home/my_backup/sql_files
if [ ! -d "$OLDBACKUP" ]; then
# create direcotry
mkdir /home/my_backup/sql_files
fi

# set file names by appending date to each file
dbName=dbName-`date -I`.sql;

# take db backups
mysqldump -u $USER -p$PASSWD -n -c myDbName >  $dbName;

# move the file to sql_files directory
mv $dbName $OLDBACKUP

We were keeping old backup files but we knew that we would need to remove the backup files older than two weeks or a month. I was thinking what to do and after some studying I found the following one line, would help us remove files older than x number of days.

find /home/my_backup/sql_files -type f -mtime +15 | xargs rm

Where 15 could be changed to any number of days and it will remove all the files older than that number of days recursively, using this command. This command won’t delete any special files or sub directories.

Testing Tools

For our testing automation and testing environment, some time ago I did some research on the available tools and also evaluated some of them.

I thought, that the tools of list I found during the research (though I didn’t try all of them) would be worth sharing with readers:

I will try to add a small description for each of the testing tool in the above list.

PHP’s empty and isset function

The best way to check if a variable consists any value or is empty is to use empty function from PHP itself.

$myVar = 0;
if (empty($myVar))
{
echo '$myVar is either 0, empty, or not set at all';
}

Though, while coding in PHP it shouldn’t be confused with isset which checks if a variable is set or not set, whether that variable is empty.

$myVar = 0;
if (isset($myVar))
{
echo '$myVar is set even though it is empty';
}

Prayers and Hope

I was thinking to write something here but always couldn’t write. I am thinking of many things at the moment and I don’t know if I would be able to implement even one from them.

Let’s pray and hope that I could write a bit reqular here and continue on the projects I have started working on.

I have changed the theme so that it feels a bit fresh on my blog :)

Domain Specific Language QA

An interesting question and answers about DSL (Domain Specific Language) with Martin Fowler.

What is a Domain Specific Language?
A Domain Specific Language (DSL) is a computer programming language of limited expressiveness focused on a particular domain. Most languages you hear of are General Purpose Languages, which can handle most things you run into during a software project. Each DSL can only handle one specific aspect of a system.

Read complete question and answers here.

What Is A Blog?

I have been following a few blogs from their beginning. Daily Blog Tips is one such excellent blog, I find it very useful as it gives me the knowledge I need to have about today’s phenomenon “Blogs”.

Yesterday Daniel Scocco of Daily Blog Tips posted an article on “What is A Blog”, which is a group writing project. I found this question of “What is A Blog” very interesting as I recently started blogging, I also wanted to share with you that what do I think of “What is A Blog”?

I think it is a platform for me:

  • To express myself
  • To share the experience I have
  • To share the knowledge I have
  • To learn from other people

As it is a group writing project, I am looking forward to read very interesting “What is A Blog” from other participants.

Final Project For CS201

Our final term for this semester is going to start in the last week of August. I am also working on the final project for my course CS201. The project I am working on is a reservation system for a bus company. It is required to have:

  • New Reservation
  • Update Reservation
  • Delete Reservation
  • Search Reservation

The deadline for this project is 9th August. So I will be busy in this and will try to post the source code, once I get the marking on this project.

I am writing this project in C/C++ and using notepad++ for writing C/C++ code.

Testing Automation Setup

On a continuation to my previous post regarding Testing Automation Tools, I will try to write the process through which I went while writing the testing scripts.

The application for which I wanted to do the automated testing is a web based application written in PHP on top of Zend Framework. As Zend Framework follows the MVC pattern, we followed the same pattern. For database, we wrote our own layer and didn’t use the layer which Zend Framework provided.

For testing automation I followed the same design rules, which I followed while designing and writing this application. I wrote testing scripts for each entity in their own files. Then I called them in one main file, which I run when I want to run the regression test. Following is an example configuration file:

//include all files, which are required to run the test cases
_include("webadmin_login.sah");
_include("webadmin_company.sah");
_include("webadmin_user.sah");
_include("webadmin_group.sah");
_include("webadmin_homepage.sah")
_include("webadmin_sysconfig.sah")
//global variables
_setGlobal("companyname", "Test_1");

// login
login("admin", "admin");

// create company info
createCompany("Test_1");
createUser("test1_user1");
createUser("test1_user2");
createUser("test1_user3");
createUser("test1_user4");
createGroup("test1_group");

// homepage
startAll();
stopAll();
refresh();

// logout
logout();

I treat this main script as my main configuration file. Where I declare some global variables, call those scripts which I need to run during my test run. I can include the scripts, which I need to run and can exclude those scripts which I don’t need.

I will continue with this series with further updates on how I wrote automated tests for every individual entity.