User Tools

(aka 'the best point military institute')

Site Tools

tools:rsync

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tools:rsync [2025/10/12 06:46] – [Remote & Network Backups] Humphrey Boa-Garttools:rsync [2025/10/12 07:40] (current) – [rsync] Humphrey Boa-Gart
Line 3: Line 3:
 **rsync** //(or **remote sync**)// is a [[tools:bash|command line]] utility for transferring and synchronizing files between any given //"source"// and //"destination"// pair. It is extremely popular for use in backup utilities, at it can synchronize backups between not only local filesystems, but also over the internet via [[tools:ssh|SSH]]. **rsync** //(or **remote sync**)// is a [[tools:bash|command line]] utility for transferring and synchronizing files between any given //"source"// and //"destination"// pair. It is extremely popular for use in backup utilities, at it can synchronize backups between not only local filesystems, but also over the internet via [[tools:ssh|SSH]].
  
-While you can technically use the ''cp -R'' command to make quick and dirty backups, ''rsync'' offers far more flexibility for common real-world scenarios.+While you can technically use the ''cp -R'' command to make quick and dirty backups, ''rsync'' offers far more flexibility for many common real-world scenarios.
  
 If you are already familiar with using [[tools:wget|Wget]] to make mirrors of entire websites, then use of ''rsync'' should come to you pretty naturally - it just operates over local filesystems & SSH instead of HTTP/HTTPS/FTP. If you are already familiar with using [[tools:wget|Wget]] to make mirrors of entire websites, then use of ''rsync'' should come to you pretty naturally - it just operates over local filesystems & SSH instead of HTTP/HTTPS/FTP.
Line 39: Line 39:
 In the case of both of these commands, //"local shell"// just means whatever terminal you are running ''rsync'' from. And no, you cannot use ''rsync'' between a remote source and remote destination at the same time: In the case of both of these commands, //"local shell"// just means whatever terminal you are running ''rsync'' from. And no, you cannot use ''rsync'' between a remote source and remote destination at the same time:
  
-  $ rsync -avz -e ssh user@remote:/source/directory/ user@remote:/destination/directory/+  $ rsync -avz -e ssh user@remote1:/source/directory/ user@remote2:/destination/directory/
   The source and destination cannot both be remote.   The source and destination cannot both be remote.
-  $  
  
-One more clarification: If you are running this from a remote machinethat machine is the "local shellin this equation, and whatever machine it is SSH'ing into is the "remote shell." Make sense? Good, because there's a few more things you have to grasp with this command, or you're going to make an absolute mess of your files.+So if you want to sync between two remote machinesyou will have to first SSH into one of them and run ''rsync'' from there "locallywith the other machine as the remote.
  
  
Line 74: Line 73:
  
   $ rsync -av --exclude-from 'exclusions.txt' /path/to/source/dir/ /path/to/destination/dir/   $ rsync -av --exclude-from 'exclusions.txt' /path/to/source/dir/ /path/to/destination/dir/
 +
 +You can even exclude things like specific filetypes:
 +
 +  $ rsync -av --exclude='*.ext' /path/to/source/dir/ /path/to/destination/dir/
  
  
Line 83: Line 86:
   * Use ''--progress'' to see real-time transfer status.   * Use ''--progress'' to see real-time transfer status.
   * Use ''--log-file=transfer.log'' to generate a log file of the transfer.   * Use ''--log-file=transfer.log'' to generate a log file of the transfer.
 +  * Use ''--remove-source-files'' to delete the source directory once the transfer is complete.
  
  
tools/rsync.1760251592.txt.gz · Last modified: by Humphrey Boa-Gart

Find this page online at: https://bestpoint.institute/tools/rsync