windows « Intelligrape Groovy & Grails Blogs

Posts Tagged ‘ windows ’

Creating a Perfect System in few minutes.

Posted by on October 22nd, 2011

There might come up a case where you need to install same kind of OS and other Softwares( which are required for daily use) on multiple systems. One of the ways to do it is follow the same procedure on each of the machines, which is obviously a pain. Here’s a easy way to do it by using Clonezilla.

Now with clonezilla you will have to setup one system only, this this would obviously take time. But once the first system is done, you can just setup rest on other machines in few minutes.

Here are the steps, that I used to follow to create system with both Windows 7 and Ubuntu in under 10 minutes. With all softwares installed which included Counter strike on windows, Couple of IDE’s on Ubuntu and Git , mySql , Java and more on Ubuntu.

  1. Setup a perfect system. Install OS and other software that are required. Once the system is ready we need to download few softwares.
    1. 7zip ( p7zip-full_9.04~dfsg.1-1_i386.deb).
    2. Tuxboot (Tuxboot-linux-8 ).
    3. Clonezilla (clonezilla-live-1.2.6-40-i686.iso).All three of these are freely available.
    4. And we would also need a USB drive preferably with space more than 16GB , as windows 7 installation takes 15 GB approx and Ubuntu 11.10 will take around 6GB and little extra for other softwares. Clonezilla uses very effective compression technique will reduce size to approx half. So 16GB USB drive would work just fine.
  2. Install CloneZilla on USB drive.
  3. Once Clonezilla is installed , its time to make image of Perfect System.
  4. After image is done, we are ready to clone out perfect system, to other machines.
  5. Making Clone of Existing image, Process to make clone are pretty much same as process described in step-3. Except Step-11 of “making image” . Just select restore disk, this will create clone of image on disk. And ALL EXISTING DATA FROM DISK WILL BE ERASED. Following  are the links of images depicting step 5.  Image 1,Image 2,Image 3,Image 4,Image 5,Image 6,Image 7,Image 8,Image 9. There images are taken from a camera, hence please don’t mind  their quality.
  6. This is it , your next system is ready within few minutes. Now this process can be repeated again and again, to create clone of existing systems.

_________________________________
Hitesh Bhatia
Mail,LinkedIn,Facebook,Twitter
_________________________________
Posted in Grails

Installing CloneZilla on USB drive using Ubuntu.

Posted by on October 22nd, 2011

Clonezilla is a software that allows you to do bare metal backup and recovery.

To install Clonezilla we would need following Softwares, all of which are available freely.

  1. 7zip ( p7zip-full_9.04~dfsg.1-1_i386.deb)
  2. Tuxboot (tuxboot-linux-8 )
  3. Clonezilla (clonezilla-live-1.2.6-40-i686.iso)

Here are the steps to install CloneZilla

  1. Install 7zip required to install Tuxboot
    1. sudo dpkg -i p7zip-full_9.04~dfsg.1-1_i386.deb
    2. It would show something like
    3. (Reading database … 168886 files and directories currently installed.)
    4. Preparing to replace p7zip-full 9.04~dfsg.1-1 (using p7zip-full_9.04~dfsg.1-1_i386.deb) …
    5. Unpacking replacement p7zip-full …
    6. Setting up p7zip-full (9.04~dfsg.1-1) …
    7. Processing triggers for man-db …
    8. And Step 1 is done. 7Zip is Installed.

2. Run tuxboot

    1. By default tuxboot is not executable , change it permission to make it.
    2. chmod +x tuxboot-linux-8
    3. Run tuxboot with sudo permission
    4. sudo ./tuxboot-linux-8
    5. Set the values as shown in image

    Step 5 - Installing Clonezilla

    5.1. Select Diskimage – then in adjacent dropdown select iso
    5.2. And then select the clonezilla image ( the one you downloaded)
    5.3. Type – usb drive
    5.4. Press “OK” . And let it complete. It will ask to reboot afterwards , but you can also reboot later

3. And your clonezilla usb is ready now. You may now use it to clone systems.

_________________________________
Hitesh Bhatia
Mail,LinkedIn,Facebook,Twitter
_________________________________
Posted in Linux, System

Using groovy execute bash scripts

Posted by on February 15th, 2011

Hi Friends,

Recently I had to execute bash script using groovy on a windows server. Though I could easily make the similar script run on linux, but on windows it just didn’t work as it was unable to recognize the internal DOS commands like cp, rm etc.

On linux the following code worked but not on windows:

 File script = new File('<My_Script_Path>')
 script.getText().execute()
 

So after trying few options, I found that we can call execute method on script path also apart from calling it directly on commands and which worked for both windows and linux, as given below :

  "<My_Script_Path>".execute()

To see the output of the script on the console, we can use the following command :

 println "<My_Script_Path>".execute().text

Hope this helped!

Cheers!
~~Amit Jain~~
amit@intelligrape.com

http://intelligrape.com

Posted in Groovy

Database Backup Script for windows

Posted by on December 14th, 2010

In one of the project I am working on, the application needs to be deployed on windows server. To take the database backup, I wrote the script which does the following :

  1. Takes database dump and copy it to the backup folder.
  2. Zip that backup file and rename it to the format “YYYYMMDD_HHMMSS”
  3. Removes  all the backups older than 30 days.

I used mysqldump command to take database backup. To zip the backup file using the command line, I found 7-zip (download) which is freely available.  We need to have forfiles.exe (download) which enables us to remove old backup files (say older than 30 days).

@echo off
CLS
set hour=%time:~0,2%
if "%hour:~0,1%" == " " set hour=0%hour:~1,1%
set min=%time:~3,2%
if "%min:~0,1%" == " " set min=0%min:~1,1%
set secs=%time:~6,2%
if "%secs:~0,1%" == " " set secs=0%secs:~1,1%
set year=%date:~-4%
set month=%date:~3,2%
if "%month:~0,1%" == " " set month=0%month:~1,1%
set day=%date:~0,2%
if "%day:~0,1%" == " " set day=0%day:~1,1%
set datetimef=%year%%month%%day%_%hour%%min%%secs%
"MYSQL_BIN_PATH\mysqldump" --user=root --password=MY_PASSWORD MY_DATABASE_NAME > "BACKUP_FOLDER_PATH\backup.sql"
"7ZIP_EXE_PATH\7z" a -tzip "BACKUP_FOLDER_PATH\"%datetimef%".zip" "BACKUP_FOLDER_PATH\backup.sql"
del "BACKUP_FOLDER_PATH\backup.sql"
"FORFILES_EXE_PATH\forfiles.exe" /p BACKUP_FOLDER_PATH /s /m *.* /d -30 /c "cmd /c del /q @path

Prerequisites for the above script to work would be :-

  1. Mysql and 7zip installed.
  2. Forfiles.exe is downloaded
  3. All the Path’s in script are replaced correctly.

I also used a background job to run this script automatically every hour on the working days. Though same can be achieved with windows scheduler too.

Hope this helped.

Cheers!
~~Amit Jain~~
amit@intelligrape.com

http://intelligrape.com/

Posted in Database