Friday, October 26, 2012

Rsync Backup Script.

This script can keep history of last 3 backups.

Source Link
http://michaeldadams.org/projects/backup/backup


#!/bin/sh

## Copyright (c) 2010-2011, Michael D. Adams
## 
## 
## Permission to use, copy, modify, and/or distribute this software for any
## purpose with or without fee is hereby granted, provided that the above
## copyright notice and this permission notice appear in all copies.
## 
## THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
## WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
## MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
## ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
## WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
## ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
## OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

set -u # Variables that are not set are errors
set -x # Print commands when executed

HOST=user@host.com
SRC=/path/to/src # no slash at end
DST=/path/to/dst # no slash at end

# If backup.0 already exists then bump age numbers and remove old backup.3
if ssh "$HOST" test -d "$DST"/backup.0; then
    ssh "$HOST" rm -rf "$DST"/backup.3
    ssh "$HOST" mv "$DST"/backup.2 "$DST"/backup.3
    ssh "$HOST" mv "$DST"/backup.1 "$DST"/backup.2
    ssh "$HOST" mv "$DST"/backup.0 "$DST"/backup.1
fi

# --progress: so we know if the program froze
# --archive:
#     recursive, links, permissions, times, group, owner, devices, specials
# --delete: remove no longer existant files in old backup.pre.
#     We don't delete the entire old backup.pre so we can do a fast restart.
# -F: use per-directory ".rync-filter" files to filter
# --rsh: tunnel over SSH
# --link-dest: share hard links to unchanged files with previous backup
rsync --progress --archive --delete -F --rsh=ssh --link-dest=../backup.1 \
  "$SRC" "$HOST":"$DST"/backup.pre &&
ssh "$HOST" mv "$DST"/backup.pre "$DST"/backup.0

Sunday, October 7, 2012

Linux Creating a Partition Size Larger Than 2TB

Creates a new GPT disklabel i.e. partition table:
(parted) mklabel gpt
Sample outputs:
Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? yes
(parted)
Next, set the default unit to TB, enter:
(parted) unit TB
To create a 3TB partition size, enter:
(parted) mkpart primary 0 2
 
 
 
 (parted) mkpart primary 2 3
 
 
 
 
*** In case you need a single partition of 3TB 
(parted) mkpart primary 0 0
 
 
To print the current partitions, enter:
(parted) printSample outputs:
Model: ATA ST33000651AS (scsi) Disk /dev/sdb: 3.00TB Sector size (logical/physical): 512B/512B Partition Table: gpt Number Start End Size File system Name Flags 1 0.00TB 3.00TB 3.00TB ext4 primaryQuit and save the changes, enter:
(parted) quit
  

Friday, October 5, 2012

sftp chroot selinux centos 6.2 - tested working

If yo want to configure secure FTP server where user cannot get out of there home directories (ie chroot environment). Please follow below steps to achieve this.

Steps for setting sftp with chroot on centos 6.

We have to create a sftpgroup first and add these users to be part of this group. All these users will be part of sftpgroup.


cp -p /etc/ssh/sshd_config /etc/ssh/sshd_config-original

vim /etc/ssh/sshd_config

*** Comment out line ---
Subsystem      sftp    /usr/libexec/openssh/sftp-server

Add these lines --- considering group name will be sftpgroup and users home directories as /home


Subsystem sftp internal-sftp

Match Group sftpgroup

ChrootDirectory /home/%u
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp

-------

groupadd sftpgroup

/etc/init.d/sshd restart

useradd -g sftpgroup -s /sbin/false amit

mkdir /home/amit/upload

chown root:root /home/amit

chmod 755 /home/amit

chown amit:sftpgroup /home/amit/upload

if you are running SE LINUX , you need give below command for all this to work.


setsebool -P ssh_chroot_rw_homedirs on


If you want user upload should go on storage below option on solve this issue.

Where /storage/home/amit is on storage box.
and /home/amit is will be a mount point.

mount -o bind /storage/home/amit /home/amit

----------------

Some part of this is learned from

http://bachradsusi.livejournal.com/2239.html


Sunday, March 18, 2012

RAID LEVEL SUMMARY

Level Techniques Description Min. Drives Failure Conditions Pros/Cons Uses


RAID O Disk striping (no fault tolerance) Data is broken into stripes which 2 When one drive fails, the entire array is compromised. Offers Best performance Video editing and production

are sent to each disk in the array.

No fault tolerance.

RAID 1 Disk mirroring Data on one drive is mirrored on another. 2 If one drive fails, data is not lost. If both drives fail, the data is lost. 100% redundancy of data/Slower performance and 50% loss of storage space. Accounting, payroll, financial

RAID 2 Byte level striping with Hamming code ECC Data is split at the bit level over a number of data and ECC disks. Up to 14+ Only one drive may fail and still be recoverable "on the fly". On the fly data error correction/Extremely high cost. No commercial uses

RAID 3 Byte level striping with dedicated parity Data is striped at the byte-level, across multiple disks. 3 When more then one drive fails, the array is compromised. High read/write data transfer rates/Complex controller design Image and video editing

RAID 4 Block level striping with dedicated parity Data is striped in blocks across data disk, with parity store on a separate disk. 3 When more then one drive fails, the array is compromised. High Read/Low Write data transaction rates. General purpose

RAID 5 Block level striping with distributed parity Data and parity are striped in blocks across all disks. 3 When more then one drive fails, the array is compromised. High Read data transaction rates/ Complex controller design Web, database or file servers

http://www.raidrecoveryguide.com/levels2.html
 

Wednesday, March 7, 2012

The 5 Qualities of Remarkable Bosses


Remarkable bosses aren’t great on paper. Great bosses are remarkable based on their actions.
Results are everything—but not the results you might think.
Consistently do these five things and everything else follows. You and your business benefit greatly.
More importantly, so do your employees.
1. Develop every employee. Sure, you can put your primary focus on reaching targets, achieving results, and accomplishing concrete goals—but do that and you put your leadership cart before your achievement horse.
Without great employees, no amount of focus on goals and targets will ever pay off. Employees can only achieve what they are capable of achieving, so it’s your job to help all your employees be more capable so they—and your business—can achieve more.
It's your job to provide the training, mentoring, and opportunities your employees need and deserve. When you do, you transform the relatively boring process of reviewing results and tracking performance into something a lot more meaningful for your employees: Progress, improvement, and personal achievement.
So don’t worry about reaching performance goals. Spend the bulk of your time developing the skills of your employees and achieving goals will be a natural outcome.
Plus it’s a lot more fun.
2. Deal with problems immediately. Nothing kills team morale more quickly than problems that don't get addressed. Interpersonal squabbles, performance issues, feuds between departments... all negatively impact employee motivation and enthusiasm.
And they're distracting, because small problems never go away. Small problems always fester and grow into bigger problems. Plus, when you ignore a problem your employees immediately lose respect for you, and without respect, you can't lead.
Never hope a problem will magically go away, or that someone else will deal with it. Deal with every issue head-on, no matter how small.
3. Rescue your worst employee. Almost every business has at least one employee who has fallen out of grace: Publicly failed to complete a task, lost his cool in a meeting, or just can’t seem to keep up. Over time that employee comes to be seen by his peers—and by you—as a weak link.
While that employee may desperately want to “rehabilitate” himself, it's almost impossible. The weight of team disapproval is too heavy for one person to move.
But it’s not too heavy for you.
Before you remove your weak link from the chain, put your full effort into trying to rescue that person instead. Say, "John, I know you've been struggling but I also know you're trying. Let's find ways together that can get you where you need to be." Express confidence. Be reassuring. Most of all, tell him you'll be there every step of the way.
Don't relax your standards. Just step up the mentoring and coaching you provide.
If that seems like too much work for too little potential outcome, think of it this way. Your remarkable employees don’t need a lot of your time; they’re remarkable because they already have these qualities. If you’re lucky, you can get a few percentage points of extra performance from them. But a struggling employee has tons of upside; rescue him and you make a tremendous difference.
Granted, sometimes it won't work out. When it doesn't, don't worry about it.  The effort is its own reward.
And occasionally an employee will succeed—and you will have made a tremendous difference in a person's professional and personal life.
Can’t beat that.
4. Serve others, not yourself. You can get away with being selfish or self-serving once or twice... but that's it.
Never say or do anything that in any way puts you in the spotlight, however briefly. Never congratulate employees and digress for a few moments to discuss what you did.
If it should go without saying, don't say it. Your glory should always be reflected, never direct.
When employees excel, you and your business excel. When your team succeeds, you and your business succeed. When you rescue a struggling employee and they become remarkable, remember they should be congratulated, not you.
You were just doing your job the way a remarkable boss should.
When you consistently act as if you are less important than your employees—and when you never ask employees to do something you don’t do—everyone knows how important you really are.
5. Always remember where you came from. See an autograph seeker blown off by a famous athlete and you might think, “If I was in a similar position I would never do that.”
Oops. Actually, you do. To some of your employees, especially new employees, you are at least slightly famous. You’re in charge. You’re the boss.
That's why an employee who wants to talk about something that seems inconsequential may just want to spend a few moments with you.
When that happens, you have a choice. You can blow the employee off... or you cansee the moment for its true importance: A chance to inspire, reassure, motivate, and even give someone hope for greater things in their life. The higher you rise the greater the impact you can make—and the greater your responsibility to make that impact.
In the eyes of his or her employees, a remarkable boss is a star.
Remember where you came from, and be gracious with your stardom.

Sunday, August 14, 2011

Search for File containing specific text.


Something
Search for a string called redeem reward in all text files located in /home/tom/*.txt directory, use

$ grep "redeem reward" /home/tom/*.txt

Task: Search all subdirectories recursively

You can search for a text string all files under each directory, recursively with -roption:

$ grep -r "redeem reward" /home/tom

Task: Only print filenames

By default, grep command prints the matching lines You can pass -H option to print the filename for each match.

$ grep -H -r “redeem reward” /home/tom

Output:

filename.txt: redeem reward

...To just print the filename use cut command as follows:

$ grep -H vivek /etc/* -R
cut -d: -f1

Output:
filename.txt

Friday, August 12, 2011

System Administrator - while joining new project. Taking hand over of Servers.

Get access credentials.

Figure out current owners of servers. Your scope in handling those servers.


Details of service running on each physical server. ( check by ps -eaf command). Get details of service running. There configuration files. Purpose.

architecture of application if running on multiple servers. Where is Database. Middle ware, Where is application running, Storage for that application.

Details of configuration files in use.

Network configuration ( IP address - iptables if running), check routes. Check all interface connected. VLAN information.

Details of backup. How they are being taken, Backup Schedule. Backup tool in use.


VERY IMPORTANT -- Try to deploy application or tool with same configuration on test environment to get total control, else iyou will always be lost.