Here is a small snippet for speeding up the process of restoration of DB from backup gunzip files
db.sh
#!/bin/bash
FILE="$1"
MYSQL=$(which mysql)
MYSQLAD=$(which mysqladmin)
GZIP=$(which gzip)
MUSER="username"
MPASS="password"
MDB="database"
echo "Droping database..."
$MYSQLAD -u $MUSER -p$MPASS drop $MDB
echo "Recreating database..."
$MYSQLAD -u $MUSER -p$MPASS create $MDB
echo "Uncompressing data..."
$GZIP -d $FILE".gz"
echo "Inserting data..."
$MYSQL -u $MUSER -p$MPASS $MDB < $FILE
USAGE:
:~/ chmod u+x db.sh
:~/ ./db.sh mysql-timestamp.sql (Remove the .gz extension while providing as a parameter)
I will add help and more parameterized functionality in due time.
Debian Eureka!!!
Blog about Debian usage
Monday, June 21, 2010
Friday, January 22, 2010
SSH, Scp, RSync, SSHFS
From days i had thought of working over it. But i thought i would do it when it would be a real requirement. But alas, they were the most interesting, easiest and handy tools for me.
SSH: Makes you the owner of a SSH enabled system through network
:~/ ssh username@ipaddress -v (and then give the password)
-v option gives you a verbose output which helps us to understand the background
For passwordless login you can generate a public key and install it in the host system.
:~/ ssh-keygen -t rsa -f filename
this generates a filename.pub in ~/.ssh directory. Then you need to copy the content of the file filename.pub into the host file .ssh/authorized_keys
SCP: This tool allows you to copy files over ssh
for a single file
:~/ scp sourcefile destination
or for a directory
:~/ scp -r sourcedirectory destination
RSync: A fabulous tool to sync files between directories using ssh. Huge amount of options are there to enable or disable certain feature. Most used feature would be just updating on local or remote directory to another one.
for local directories
:~/ rsync -auv sourcedirectory destinationdirectory
or else you can do between a remote location
:~/ rsync -auv user@ip:relativepath/sourcedirectory destinationdirectory
The above one's don't delete destination files which are not in the source.
SSHFS: This tool enables us to mount the host system directory into our filesystem
:~/ sshfs user@ip:relativepath/sourcedirectory destinationdirectory
This enables us to treat the remote directory as a part of our system. Share your thoughts and also post info on some other ssh tools.
SSH: Makes you the owner of a SSH enabled system through network
:~/ ssh username@ipaddress -v (and then give the password)
-v option gives you a verbose output which helps us to understand the background
For passwordless login you can generate a public key and install it in the host system.
:~/ ssh-keygen -t rsa -f filename
this generates a filename.pub in ~/.ssh directory. Then you need to copy the content of the file filename.pub into the host file .ssh/authorized_keys
SCP: This tool allows you to copy files over ssh
for a single file
:~/ scp sourcefile destination
or for a directory
:~/ scp -r sourcedirectory destination
RSync: A fabulous tool to sync files between directories using ssh. Huge amount of options are there to enable or disable certain feature. Most used feature would be just updating on local or remote directory to another one.
for local directories
:~/ rsync -auv sourcedirectory destinationdirectory
or else you can do between a remote location
:~/ rsync -auv user@ip:relativepath/sourcedirectory destinationdirectory
The above one's don't delete destination files which are not in the source.
Once we got max speed @ 12 MB/s in our 100 Mbps network while backing up a computer. Most of us were astonished as the content was multiple files. Have to research about rsync.
SSHFS: This tool enables us to mount the host system directory into our filesystem
:~/ sshfs user@ip:relativepath/sourcedirectory destinationdirectory
This enables us to treat the remote directory as a part of our system. Share your thoughts and also post info on some other ssh tools.
Tuesday, November 24, 2009
Image magick
Few days ago, i was given a task to create a gallery for a website. The images i got were around 3000x2000 resolution, each having 3 MB size. I thought to down scale those images so that i could easily upload and manage them in the gallery of the website. Then came "Imagemagick" into the scene. With just a line of shell command i converted 300 odd images into 600x400 resolution.
:~/ convert *.JPG -scale 600x480 output.jpg
You need to have the imagemagick package to use this command. You can just do an
:~/ apt-get install imagemagick
The output files will be created like output-0.jpg, output-1.jpg, etc...
:~/ convert *.JPG -scale 600x480 output.jpg
You need to have the imagemagick package to use this command. You can just do an
:~/ apt-get install imagemagick
The output files will be created like output-0.jpg, output-1.jpg, etc...
Thursday, September 3, 2009
Agave - Color scheme generator
AGAVE is a package available for GNU/Linux, which enables to choose color schemes easily. It generates contemprary colors to a color choosen, making the task of a theme developer easier. The most important option obtained by the package is the eyedropper (The tool used to get color code of any color visible on the screen). This is the most important option for any theme developer.
Tuesday, June 9, 2009
Lynx - Terminal Browser
Lynx is a cursor-addressable browser which can run on terminal itself. The coolest part is that it runs with cool colors and is also easily navigable using direction keys and some confirmation keys. It prompts for some actions to press (y | n .... and adds more functionality to it.
Monday, June 8, 2009
Configuring Nagios
Nagios is a Network monitoring software which uses samba server to serve the localhost with all the monitored information of the network. It actively monitors specified services on specified hosts. I was looking for a tool to put it in the server of the computer lab so that we could do some remote monitoring of the clients. I was successful a bit, as i couldn't remotely ssh clients to run some scripts. I think i have to work more on it so that i could learn all the features of Nagios.
Configuring Nagios
I followed the guide provided by http://www.myelin.co.nz/post/2008/10/30/#200810301 . I successfully confgiured Nagios on a system. The toughest job was to put all the hosts on the hosts.cfg file in the nagios3/conf.d/
I had manually enter all the 150 odd local ip's in the file. Then success came fast then expected. i was seeing screen which filled my heart with happiness. Nagios is a perfect package for remotely monitoring clients.
I also consulted some guys on irc chat who specified to use these tools for remotely running shell scripts on clients :
1. DSH
2. PyDSH
3. Puppet
4. CFengine
5. Fai-server
If time allows, i would explore the above mentioned and put them in my blog. Or may be i would unlock the ssh feature in Nagios itself.
Configuring Nagios
I followed the guide provided by http://www.myelin.co.nz/post/2008/10/30/#200810301 . I successfully confgiured Nagios on a system. The toughest job was to put all the hosts on the hosts.cfg file in the nagios3/conf.d/
I had manually enter all the 150 odd local ip's in the file. Then success came fast then expected. i was seeing screen which filled my heart with happiness. Nagios is a perfect package for remotely monitoring clients.
I also consulted some guys on irc chat who specified to use these tools for remotely running shell scripts on clients :
1. DSH
2. PyDSH
3. Puppet
4. CFengine
5. Fai-server
If time allows, i would explore the above mentioned and put them in my blog. Or may be i would unlock the ssh feature in Nagios itself.
Sunday, June 7, 2009
Using grep and cut
Grep and cut are some of the tools used for text processing. They use regular expressions to filter out specific terms in a file
Task : To find out the IP Address from Ifconfig
Solution : ifconfig eth0 | grep "inet addr" | cut -d ":" -f 2 | cut -d "B" -f 1
Explanation :
1. ifconfig eth0 (Displays network settings for your pc)
2. grep "inet addr" (Filters lines to the line containing string "inet addr")
3. cut -d ":" -f 2 (Cuts the obtained line into columns using delimiter ":" and then displays the 2nd column)
4. cut -d "B" -f 1(Cuts the obtained line into coumns using delimiter "B" and then displays the 1st column)
Task : To find out the IP Address from Ifconfig
Solution : ifconfig eth0 | grep "inet addr" | cut -d ":" -f 2 | cut -d "B" -f 1
Explanation :
1. ifconfig eth0 (Displays network settings for your pc)
2. grep "inet addr" (Filters lines to the line containing string "inet addr")
3. cut -d ":" -f 2 (Cuts the obtained line into columns using delimiter ":" and then displays the 2nd column)
4. cut -d "B" -f 1(Cuts the obtained line into coumns using delimiter "B" and then displays the 1st column)
Subscribe to:
Posts (Atom)