Rsync: Difference between revisions

From Network Security Wiki
Content added Content deleted
m (Protected "Rsync" ([Edit=Allow only logged in users] (indefinite) [Move=Allow only logged in users] (indefinite) [Delete=Allow only logged in users] (indefinite)))
 
Line 4: Line 4:
Rsync instance need to be installed on both server & client for rsync to work.
Rsync instance need to be installed on both server & client for rsync to work.


=One-Liners=
= One-Liners =

* Synchronize Two Directories in a Local Server
* Synchronize Two Directories in a Local Server
rsync -zvr /var/opt/installation/inventory/ /root/temp
rsync -zvr /var/opt/installation/inventory/ /root/temp

* Synchronize Only One File
* Synchronize Only One File
rsync -v /var/lib/rpm/Pubkeys /root/temp/
rsync -v /var/lib/rpm/Pubkeys /root/temp/

* Synchronize Files From Local to Remote
* Synchronize Files From Local to Remote
rsync -avz /root/temp/ thegeekstuff@192.168.200.10:/home/thegeekstuff/temp/
rsync -avz /root/temp/ thegeekstuff@192.168.200.10:/home/thegeekstuff/temp/

* Synchronize Files From Remote to Local
* Synchronize Files From Remote to Local
rsync -avz thegeekstuff@192.168.200.10:/var/lib/rpm /root/temp
rsync -avz thegeekstuff@192.168.200.10:/var/lib/rpm /root/temp

* Remote shell for Synchronization
* Remote shell for Synchronization
rsync -avz -e ssh thegeekstuff@192.168.200.10:/var/lib/rpm /root/temp
rsync -avz -e ssh thegeekstuff@192.168.200.10:/var/lib/rpm /root/temp

* Do Not Overwrite the Modified Files at the Destination
* Do Not Overwrite the Modified Files at the Destination
rsync -avzu thegeekstuff@192.168.200.10:/var/lib/rpm /root/temp
rsync -avzu thegeekstuff@192.168.200.10:/var/lib/rpm /root/temp

* Synchronize only the Directory Tree Structure (not the files)
* Synchronize only the Directory Tree Structure (not the files)
rsync -v -d thegeekstuff@192.168.200.10:/var/lib/ .
rsync -v -d thegeekstuff@192.168.200.10:/var/lib/ .

* View the rsync Progress during Transfer
* View the rsync Progress during Transfer
rsync -avz --progress thegeekstuff@192.168.200.10:/var/lib/rpm/ /root/temp/
rsync -avz --progress thegeekstuff@192.168.200.10:/var/lib/rpm/ /root/temp/

* Resume Support
rsync -avz --partial --progress thegeekstuff@192.168.200.10:/var/lib/rpm/ /root/temp/
rsync -avzP thegeekstuff@192.168.200.10:/var/lib/rpm/ /root/temp/

* Delete the Files Created at the Target
* Delete the Files Created at the Target
rsync -avz --delete thegeekstuff@192.168.200.10:/var/lib/rpm/ .
rsync -avz --delete thegeekstuff@192.168.200.10:/var/lib/rpm/ .

* View the Changes Between Source and Destination
* View the Changes Between Source and Destination
rsync -avzi thegeekstuff@192.168.200.10:/var/lib/rpm/ /root/temp/
rsync -avzi thegeekstuff@192.168.200.10:/var/lib/rpm/ /root/temp/

* Include and Exclude Pattern during File Transfer
* Include and Exclude Pattern during File Transfer
rsync -avz --include 'P*' --exclude '*' thegeekstuff@192.168.200.10:/var/lib/rpm/ /root/temp/
rsync -avz --include 'P*' --exclude '*' thegeekstuff@192.168.200.10:/var/lib/rpm/ /root/temp/

* Do Not Transfer Large Files
* Do Not Transfer Large Files
rsync -avz --max-size='100K' thegeekstuff@192.168.200.10:/var/lib/rpm/ /root/temp/
rsync -avz --max-size='100K' thegeekstuff@192.168.200.10:/var/lib/rpm/ /root/temp/

* Transfer the Whole File
* Transfer the Whole File
rsync -avzW thegeekstuff@192.168.200.10:/var/lib/rpm/ /root/temp
rsync -avzW thegeekstuff@192.168.200.10:/var/lib/rpm/ /root/temp

* Rsync between Ubuntu and Windows
* Rsync between Ubuntu and Windows
sudo apt-get install smbfs
sudo apt-get install smbfs

Latest revision as of 01:22, 15 April 2020

Introduction

Rsync instance need to be installed on both server & client for rsync to work.

One-Liners

  • Synchronize Two Directories in a Local Server
rsync -zvr /var/opt/installation/inventory/ /root/temp
  • Synchronize Only One File
rsync -v /var/lib/rpm/Pubkeys /root/temp/
  • Synchronize Files From Local to Remote
rsync -avz /root/temp/ thegeekstuff@192.168.200.10:/home/thegeekstuff/temp/
  • Synchronize Files From Remote to Local
rsync -avz thegeekstuff@192.168.200.10:/var/lib/rpm /root/temp
  • Remote shell for Synchronization
rsync -avz -e ssh thegeekstuff@192.168.200.10:/var/lib/rpm /root/temp
  • Do Not Overwrite the Modified Files at the Destination
rsync -avzu thegeekstuff@192.168.200.10:/var/lib/rpm /root/temp
  • Synchronize only the Directory Tree Structure (not the files)
rsync -v -d thegeekstuff@192.168.200.10:/var/lib/ .
  • View the rsync Progress during Transfer
rsync -avz --progress thegeekstuff@192.168.200.10:/var/lib/rpm/ /root/temp/
  • Resume Support
rsync -avz --partial --progress thegeekstuff@192.168.200.10:/var/lib/rpm/ /root/temp/
rsync -avzP thegeekstuff@192.168.200.10:/var/lib/rpm/ /root/temp/
  • Delete the Files Created at the Target
rsync -avz --delete thegeekstuff@192.168.200.10:/var/lib/rpm/ .
  • View the Changes Between Source and Destination
rsync -avzi thegeekstuff@192.168.200.10:/var/lib/rpm/ /root/temp/
  • Include and Exclude Pattern during File Transfer
rsync -avz --include 'P*' --exclude '*' thegeekstuff@192.168.200.10:/var/lib/rpm/ /root/temp/
  • Do Not Transfer Large Files
rsync -avz --max-size='100K' thegeekstuff@192.168.200.10:/var/lib/rpm/ /root/temp/
  • Transfer the Whole File
rsync -avzW  thegeekstuff@192.168.200.10:/var/lib/rpm/ /root/temp
  • Rsync between Ubuntu and Windows
sudo apt-get install smbfs
sudo mount -t smbfs //LASTXP21/Data /mnt/data -o username=administrator,password=,rw
pkexec rsync -r -t -v --progress --ignore-existing -u -s /data/.personal/shotwell/ /mnt/data/Shotwell


{{#widget:DISQUS |id=networkm |uniqid=Rsync |url=https://aman.awiki.org/wiki/Rsync }}