Posted On August 24, 2021

Linux: RSYNC Examples

kimconnect 0 comments
blog.KimConnect.com >> Linux >> Linux: RSYNC Examples

Following are a few practical uses of this command:

# Copying from a Local Directory to another
# Important: to set source and destination directories, one must include the trailing slash '/' to identify object as a directory
source=/media/kim/2849-2EAD/doanclub_kimconnect/
destination=/media/data/doanclub_kimconnect/
rsync -a $source $destination

# Copying in to a directory that does NOT yet exist
# Note: these extra switches would display progress
localsource=/var/lib/docker/
localdestination=/nfs-share/linux03/docker/
mkdir -p $localdestination && rsync -avhP --stats --progress $localsource $localdestination

# Copying with exclusions
source=/media/kim/2849-2EAD/
excludeDirectory=.Trash-1000
destination=/media/data/
rsync -a --exclude=$excludeDirectory $source $destination

# Copying from a Local Directory to a remote machine
rsync -a /media/data/ remote_user@remote_host_or_ip:/media/data/

# Copying from Local to Remote using uncommon port
rsync -a -e "ssh -p 22222" /media/data/ remote_user@remote_host_or_ip:/media/data/

# Copying from Remote to Local
rsync -a remote_user@remote_host_or_ip:/media/data/ /media/data/

# Copying from Remote to Local using a 'screen' session (terminal multiplexer)
rsync -a -P remote_user@remote_host_or_ip:/media/data/ /media/data/

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

PowerShell: Probe Remote Machine for Its OS Type

function probeOsType($server){ $ping=test-connection $server -count 1 $ttl=$ping.ResponseTimeToLive $osType=switch($ttl){ {$_ -le 64} {"Linux"; break} # MacOs…

Linux: Check CPU Utilization

There are many utilities that would provide this information. The easiest one that is available…

How To Install Graylog in a Kubernetes Cluster Using Helm Charts

The following narrative is based on the assumption that a Kubernetes (current stable version 20.10)…