Wednesday, June 14, 2017

Script to backup application and database in linux

TIME=`date +%y%m%d`
#tar -zcvf /data/backup/ $TIME-folderapps-site.tar.gz data/folderapps

mysqldump -h172.15.100.22 -udb_admin -pP@ssW0rD --default-character-set=utf8 database_apps26 > $FILENAME1
#backup database

Monday, January 16, 2017

Failover Cluster can’t access when Disk Quorum witness is outage

The problem is when the disk quorum witness is full, we cannot expend or do anything.

Here is the solution that we did;

1. The "disk quorum" which is offline -> we remove it from the "Failed Cluster Manager"-Storage-Disks- Disk quorum- right click remove

2. In my case : the disk is "Disk 1"

PowerShell command:
Clear-ClusterDiskReservation –Disk
In my case : Clear-ClusterDiskReservation –Disk 1

Then, resize the harddisk by making it online -> right click-> extend

Finish -> then right click -> offline the hardisk

3. Then add back the disk (Add Disk) to the cluster storage;

4. Then configure cluster quorum settings ->  use default quorum configuration setting.

Tuesday, January 10, 2017

Apache 2.4 from 2.2

Here is the refference of changes in apache 2.4 from apache 2.2.

From :
    AllowOverride none
    Require all granted

        Options Indexes FollowSymLinks MultiViews
        AllowOverride FileInfo  All
        Order allow,deny
        Allow from all
        Require all granted

Wednesday, November 23, 2016

Upgrade Ubuntu 14.05 to Ubuntu 16.04

Here is the step: (but may be there is some lack here and there in the step)

At the first step I try to upgrade using this step: 

Then everything turn problem.. All services cannot started :( 

Here we go.. lets find out the solution :)
1. I notice that the version of php5 is already replace with php7. Which maybe the culprit of this problem. 
2. Mysql also cannot restart. 
3. Nginx problem because of the php5-fpm already deinstall and cannot be install again. 

Ok.. Lets start to patch;
1. uninstall all the package including all the dependancy of the package mysql.
#dpkg -P --force depends mysql-server mysql-server-5.7 mysql-common mysql-server-core-5.7 php5-mysql mysql-client-5.7 mysql-client-core-5.7 libdbd-mysql-perl libmysqlclient18:amd64 libmysqlclient20:amd64

2. uninstall all the package including all the dependancy of php
#apt-get purge php5-common php5-curl php5-json php5-mysql

3. unistall nginx 
#apt autoremove nginx

Then reinstall back
1. apt-get install mysql-server mysql-client mysql-common dbconfig-mysql
2. apt-get install php-fpm php-mysql

Changes in Mysql

#systemctl stop mysql

#nano /etc/mysql/mysql.conf.d/mysqld.cnf

#nano /etc/apparmor.d/tunables/alias
alias /var/lib/mysql/ -> /mnt/data/mysql/,

#systemctl restart apparmor
#systemctl start mysql


Changes in php
Do some changes at 
#nano /etc/php/7.0/fpm/php.ini

#systemctl status php7.0-fpm
#systemctl start php7.0-fpm

Changes in Nginx
#nano /etc/nginx/sites-available/default 
fastcgi_pass unix:/run/php/php7.0-fpm.sock;


Others command;
apt-cache show mysql-server | grep Version    ; check version mysql 
dpkg --get-selections | grep php      ; check list package with php
lsb_release -a          ;check version ubuntu
nginx -t      ;test nginx config

Tuesday, November 1, 2016

File Transfer With On-the-fly Compression

I want to copy a folder from 1 server to another server with smart way.
1. Because not enough space to extract in current server. 
2. To transfer big files with minimal time.

Here is the command; 
Run this at "server source" 
tar czf - /path/to/copy/folder | ssh shariha@serverdestination tar xzf - -C /path/to/place

server source: : want to copy folder /data/folder1
server destination: : want to place it at  /data/migrate/

run at
tar czf - /data/folder1 | ssh shariha@ tar xzf - -C /data/migrate/

ps: this will tar the folder and untar directly to the path that we want to place it. :) 

Nice :) 

Tuesday, August 2, 2016

Cramp with vi

Change default setting vi to ee
#setenv EDITOR ee

Rsync and Backup Ldap Data


HOST=root@   #eg: ip backup server =
SRC=/backup # no slash at end
DST=/ldapbackup/students # no slash at end
TDAY=$(date -j +%Y%m%d) # Current date

#********************* Start Debug **********************************
# For debuging only enable line below:

#set -u # Variables that are not set are errors
#set -x # Print commands when executed
#/usr/bin/touch -t `date -j -v -744H '+%Y%m%d%H%M'` "$SRC"/test-30day-older.txt  # create test file older than 30 days
/usr/bin/find /backup/ -type f -mtime +60 -delete #delete file older than 60 days

#******************** End Debug *************************************

#******* Backup openldap config /usr/local/etc/openldap ******#
#/usr/local/bin/rsync -az /usr/local/etc/openldap/ root@

#******* Backup OpenLdap Data & Compress ******#
/usr/local/sbin/slapcat | /usr/bin/gzip > "$SRC"/StudentLdap.$TDAY.gz

#***** Create MD5 File for verification ********#
/sbin/md5 "$SRC"/StudentLdap.$TDAY.gz > "$SRC"/StudentLdap.$TDAY.md5

#******* Set File Permission (allow only root) ******#
/bin/chmod 0600 "$SRC"/StudentLdap.$TDAY.*

#******* Find File older than 31 days and write to log file ******#
/usr/bin/find "$SRC"/ -type f -mtime +31  > "$SRC"/older_log.txt

#******* Run Rsync and copy backup to $HOST:$DST  and --delete to delete files which is no longer in source
/usr/local/bin/rsync --delete -az /backup/ "$HOST":"$DST"/

#******* Enable this and disable above line if need verbose
#/usr/local/bin/rsync -avz /backup/ "$HOST":"$DST"/