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

Linux: Using Bash to Search for Files Matching Certain Extensions

# using tree: list any files in a directory parentDirectory=/home tree --prune $parentDirectory # using…

How to Disable SELINUX on CentOS 8

SELinux is a sort of system-call firewall, where processes are in their run spaces. When…

Ubuntu 20.04: Setting Static IP Address on an Interface

Short Version # Configure networking sudo vim /etc/netplan/*.yaml ### Sample content ### network: version: 2…