sobota, 14 czerwca 2014

OpenLDAP backup and restore

I'm going to change some schema and data in my ldap ;)

But 1st thing is how to restore ldap from ldiff file when something will go bad ...

1st is backup
2nd is store backup on other host/disk/whatever, it can be printed each time ;)
3rd is how to restore it when disaster come true ...

1st) backup like this? hm ... put it to cron ;)

[root@samba64 tmp]# slapcat  -o ldif-wrap=no > slapcat-o-ldif-wrap-n.ldiff


2nd) when file is created send it somewhere ;)

3rd) restore from ldiff file, please remember about correct schema files,
if there is something 'strange' (my setup has some tweaks for Postfix) then also backup schema files :P just in case :P ;-) 

how to restore it?

- shut down ldap server,
- remove broken files, in my case just clean directory /var/lib/openldap-data or rename it,
-  change directory to /var/lib/openldap-data,
- do command: slapadd -v -l ~/LDAP/slapcat-o-ldif-wrap-n.ldiff,
- chown slapd:slapd files in /var/lib/openldap-data (beware, it is my PLD Linux ;) ),
- start ldap,
- check it. something like this:

ldapsearch  -b "ou=Users,dc=XXXX,dc=pl" -D "cn=Manager,dc=XXXX,dc=pl" \
        -w MyPassword -x -v \
        -h 127.0.0.1\
        '(&(objectClass=PostfixUser)(accountStatus=active))' mail

Uff done ...

Restore procedure looks like "IT WORKS!"

:-)

Next step is add and change some data in my secret schema ;) then do some tricks with ldiff file ...


środa, 14 maja 2014

Sun ultra 10


Back to home :)
Sun ultra 10, 450mhz, 512 mb, 2x hdd ata 20gb

Power of SQL

And again ... I've discovered power of SQL in PostgreSQL db ...

begin;

insert into przetargi_zalaczniki
(
    przetarg_id,
    zalacznik,
    plik,
    createdby,
    datapublikacji
 )
select 991, zalacznik, plik, createdby, '2014-05-14 14:55:05'
from przetargi_zalaczniki
where przetarg_id=970;

commit;

wtorek, 1 kwietnia 2014

Power of sfdisk

sfdisk -d /dev/sda > file

cat file | sfdisk /dev/sdb
cat file | sfdisk /dev/sdc
cat file | sfdisk /dev/sdd


;)
maybe ...

czwartek, 13 marca 2014

OMG ... vim ... and spaces ...

Simple shot.

File, in file some columns, where one line looks like this (some part from
psql -l -U username)

 niet            | niet    | UTF8
 postgres    | postgres | UTF8
 template0  | postgres | UTF8
 template1  | postgres | UTF8
 testowa     | postgres | UTF8
 testowa1   | mzdw     | UTF8
 testowisko | postgres | UTF8

I need only 1st word from line.

Commands
:1 (move to 1st line)
V (select line)
G (move to end of test and also keep selected)

Then press : (will see this->     :'<,'>   )

Type: s/ .*// and press Enter

And all go off ;)
Why ?

Thats why, because 1st character is a space before 'niet, and other dbnames'.

Press u (it will undo changes).

Now, let be a little smart ;) ?????

:1
V
G
:'<,'>s/^ // | '<,'>s/ .*//g

Tap enter and again enter :D


Uff ;)

New parts for hobby

New parts for hobby

środa, 12 marca 2014

For example, there is two pids, 12344 and 23444 which was 1st?

Last time at job interview I was asked about pids on Linux system.

For example, there is two pids, 12344 and 23444 which was 1st?

At 1st shot pids start from 1 for init then pid grow up, usually per 1 ;)
but nowadays Linux kernel has 'magic' option, which 'mix' pid.
They are not counted step by step ;)

There is some free spaces between pid numbers, some app start, then stop,
kernel works and thinks which pid give.


[root@mail ~]# ps -eo pid,lstart,cmd
  PID                  STARTED CMD
    1 Fri Mar  7 09:38:00 2014 init [3] 
    2 Fri Mar  7 09:38:00 2014 [kthreadd]
    3 Fri Mar  7 09:38:00 2014 [ksoftirqd/0]
    5 Fri Mar  7 09:38:00 2014 [kworker/0:0H]
------
 3942 Fri Mar  7 09:41:47 2014 /usr/sbin/httpd -f /etc/httpd/apache.conf
 9727 Mon Mar 10 12:49:14 2014 /sbin/mingetty --noclear tty1
10527 Fri Mar  7 11:36:32 2014 /usr/sbin/sshd

-------
17901 Wed Mar 12 12:14:45 2014 dovecot/pop3-login
17903 Wed Mar 12 12:14:58 2014 ps -eo pid,lstart,cmd
18252 Sat Mar  8 01:40:34 2014 dovecot/auth
22125 Mon Mar 10 05:02:06 2014 /usr/sbin/fcgi- -f /etc/httpd/apache.conf


Whatever ...