How to export Tivoli Directory Server to .ldif file

This script is simply and usefull to backup all users in a tivoli directory server to an ldif file.
When schedule by crontab it’s possible to add in command line destination folder by $1 param,
so you can have different versions of backup.

1
2
3
4
5
6
7
8
9
10
11
12
13
#!/bin/sh
 
NOW=$(date +"%u")
LPATH=/tmp/juve_full_backup$NOW.ldif
RPATH=/backup/ldap/$1
LOG=/var/log/bckLdap$1"-"$NOW".log"
 
echo "------------------"Backup LDAP on DOW $NOW"----------------------------------">LOG
echo `date`>>$LOG
 
mkdir $RPATH
/opt/IBM/ldap/V6.3/sbin/idsdb2ldif -I juvetds1 -o $LPATH  >$LOG
mv $LPATH $RPATH

Mysql Usefull Commands

Here some usefull command to administer Mysql Database Server:
#Access command line:
mysql -uroot -upassword

#Viev all user:
select user,password,host from mysql.user;

#Enable root remote login :
GRANT ALL PRIVILEGES ON *.* TO ‘root’@’%’ IDENTIFIED BY ‘password’;
FLUSH PRIVILEGES;
exit;

#Execute Mysql command from bash:

mysql -uroot -e “create database prod”
mysql -uroot -e “CREATE USER ‘prod’@’%’ IDENTIFIED BY ‘MyProd016′”
mysql -uroot -e “GRANT ALL PRIVILEGES ON prod.* TO ‘prod’@’%’ WITH GRANT OPTION”
mysql -uroot -e “FLUSH PRIVILEGES”
exit;

Imagemagick power resizer command

This command is usefull to resize only images greater than x in a folder.It put resized images in a folder called thumbs but you can convert file implace deleting “thumb/” string.

1
for i in `ls *.jpg`; do convert $i -resize 800x800\> thumb/$i ; done

Lvm Extend Volume Group adding new Disk

These are the step to add space to and existing Logical Volume on a Volume Group:

1) add disk and perform  rescan-scsi-bus.sh
2) Add Physical Volume available for LVM:

pvcreate (-t)* /dev/sdc

3) Exteng the volume group (here namend system) with new create physical volume:

vgextend (-t)* system /dev/sdc

4) Extend target logical volume (here named /dev/system/opt) with new space (here 10gb):

lvextend -L +10G -t /dev/system/opt

5) verify :

lvmdisplay

6) In the end you have to resize physical space :

resize2fs /dev/system/opt

 

*Always by tiping -t you can test command before execute on production server.

Hotw to tunnel by ssh from local server to remote One.

Taken From : http://www.revsys.com/writings/quicktips/ssh-tunnel.html

ssh -f user@personal-server.com -L 2000:personal-server.com:25 -N

(working example ssh -f root@192.168.40.91 -L 0.0.0.0:8585:192.168.40.91:8585 -N)
The -f tells ssh to go into the background just before it executes the command. This is followed by the username and server you are logging into. The -L 2000:personal-server.com:25 is in the form of -L local-port:host:remote-port. Finally the -N instructs OpenSSH to not execute a command on the remote system.

To kill tunnel use:

 netstat -anp | grep 8585    —–> find process ID
kill -9 process ID