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

How to Transfer Files Via SSH or WinRM

Secured Shell (SSH) is the prevalent standard for remote accessing of Linux systems. Even Microsoft…

NextCloud Container PHP Memory Issue as Deployed via Kubernetes

Most common example:Below is a raw text paste of an exercise in resolving the issue…

CentOS 5: Installing XAMPP, and Gallery2

1. Install CentOS 5 - Do not install MySQL, Apache, and FTP - edit /etc/resolv.conf…