Friday, August 26, 2016

Data Migration/Copy/Backup Using rsync command in Linux

rsync - stands for remote sync

rsync is used to perform the backup operation/data Migration in UNIX / Linux.
rsync utility is used to synchronize the files and directories from one location to another in an effective way. Backup location could be on local server or on remote server

Syntax

$ rsync options source destination
Source and destination could be either local or remote. In case of remote, specify the login name, remote server name and location.
options:
  • -z is to enable compression
  • -a = archive ( it preserves permissions (owners, groups), times, symbolic links, and devices  =  -rlptgoD)
  • -v verbose     ( it shows on the screen what is being copied )
  • -r indicates recursive ( it copies directories and sub directories)
  • -e rsync will use ssh
Examples:

Synchronize Two Directories in a Local Server

$ rsync -zvr /tmp/source_dir/ /destination_dir

Preserve timestamps during Sync using rsync -a

$ rsync -azv /tmp/source_dir/ /destination_dir/

Synchronize Files From Local to Remote

rsync -avz /tmp/source_dir/ user@192.168.1.1:/tmp/destination_dir/
Password:

Synchronize Files From Remote to Local

rsync -avz user@192.168.1.1:/tmp/remote_source_dir/ /tmp/local_destination_dir/
Password:

rsync using ssh

rsync -avz -e ssh user@192.168.1.1:/tmp/remote_source_dir/ /tmp/local_destination_dir/
Password:

View the Progress during rsync Transfer

rsync -avz --progress user@192.168.1.1:/tmp/remote_source_dir/ /tmp/local_dest_dir/
Password:

Specify --max-size of file for rsync Transfer (>100K will not be transfer)

rsync -avz --max-size='100K' user@192.168.1.1:/tmp/remote_srce_dir/ /tmp/local_dest_dir/
Password:

Transfer the Whole File with rsync -W

normally rsync transfers only the changed block to the destination, instead of sending the whole file, with the option -W it transfer the whole file

rsync -avzW user@192.168.1.1:/tmp/remote_srce_dir/ /tmp/local_dest_dir/
Password:

Wednesday, July 13, 2016

Mount NTFS Partition in RHEL/CentOS


Enable NTFS support on CentOS Linux version 5 or 6? 
Mount ntfs partition under RHEL 5 or 6?

First need to install EPEL repo on RHEL / CentOS version 6.x

# cd /tmp
# wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-5.noarch.rpm


# yum install epel-release-6-5.noarch.rpm

NTFS-3G
NTFS-3G is a stable, open source, GPL licensed, POSIX, read/write NTFS driver for Linux.
It provides safe handling of the Windows XP, Windows Server 2003, Windows 2000, Windows Vista, Windows Server 2008 and Windows 7 NTFS file systems.
NTFS-3G can create, remove, rename, move files, directories, hard links, and streams.
it can read and write normal and transparently compressed files, including streams and sparse files.
it can handle special files like symbolic links, devices, and FIFOs, ACL, extended attributes.
moreover it provides full file access right and ownership support.

Install NTFS-3G 


# yum install ntfs-3g


Find Out NTFS Partition Name


# fdisk -l /dev/sda
# fdisk -l /dev/sdb

How to Mount /dev/sda1 NTFS Partition at /mnt/ntfs


load the fuse driver
# modprobe fuse

Create a mount point
# modprobe fuse

mount the ntfs partition, enter:
# mount -t ntfs-3g /dev/sda1 /mnt/ntfs

You can use regular Unix commands to copy or access the files:
df -h
 mount
 cd /mnt/ntfs
cp test /tmp

Unmount NTFS Partition


# umount /mnt/ntfs