27

As far as I undstand, the following command:

sudo rsync --delete -azvr /home/oshiro/Desktop/source/ /home/oshiro/Desktop/destination

Is this all I need to create a simple synchronisation of files from 1 location to another? Or does the above command do anything more in the background which I don't know about? For example, does it create some sort of versioning, where I can specify a past time to get files how where were in the passed?

That's a feature which I do not want to enable at this stage. All I want is bit-identical copy of the files from 1 location to another. Can I get rid of any of those parameters or do I need to add further parameters to make the copies bit-identical with no versioning. Basically, I don't want to create backups how the mac time machine backup system creates backups.

3 Answers 3

28

Rsync doesn't do any kind of versioning or keep any history unless instructed with options such as --backup. There are backup tools that use rsync, but rsync itself isn't a backup tool any more than four wheels make a car. Rsync just handles the synchronization.

Regarding the options you used or might want to use:

  • -a means “copy almost everything” (copy directories recursively, copy symbolic links as such, preserve all metadata, etc.). Use this option unless you're doing something unusual.
  • In addition to -a, you may want to use -H to preserve hard links, -A to preserve ACLs (-a only preserves traditional unix permissions), or -X to preserve extended attributes.
  • -r is already included in -a.
  • -v means verbose.
  • -z is useless for a local copy.
  • --delete deletes files in the destination that are not present in the source.

So this is the basic command to make the destination identical to the source (absent hard links, ACLs and extended attributes):

rsync -a --delete SOURCE/ DESTINATION/
17

I usually use the command from this answer. The advantage is that it also preserves extended attributes and ACLs.

rsync -avxHAX --info=progress2 / /new-disk/

The options are:

-a  : all files, with permissions, etc..
-v  : verbose, mention files
-x  : stay on one file system
-H  : preserve hard links (not included with -a)
-A  : preserve ACLs/permissions (not included with -a)
-X  : preserve extended attributes (not included with -a)

A note about the sync progress of progress2: rsync incrementally scans for files to scan ("incremental recursion"). The output of this incremental recursion is shown in progress2's ir-chk output. However, until all files are scanned, the progress percentage is misleading, because rsync doesn't yet know how much files are to be transferred. To first check all the files and only then start syncing, add the --no-inc-recursive option.

3

This command should be all you need. rsync by default uses what's called a quick check algorithm:

Rsync finds files that need to be transferred using a "quick check" algorithm (by default) that looks for files that have changed in size or in last-modified time. Any changes in the other preserved attributes (as requested by options) are made on the destination file directly when the quick check indicates that the file’s data does not need to be updated.

This is often fine in most applications. It's quicker than the alternative method which calculates a checksum for each file. This second method will guarantee tracking differences that might slip by the first method.

In any case rsync does not keep multiple copies of files it's a gross file copier/synchronizer keeping one directory synchronized with another per the options that you give it.

Checksum method

If you're curious here's the switching I use to rsync to perform this type of sync:

$ rsync -avvz -O --stats --checksum --human-readable --acls \
    --itemize-changes --progress \
    --out-format='[%t] [%i] (Last Modified: %M) (bytes: %-10l) %-100n' \
    "SRC" "DEST"

This generates this type of output:

2014/02/20 09:51:49 INFO sending incremental file list 
2014/02/20 09:51:49 INFO delta-transmission disabled for local transfer or --whole-file 
2014/02/20 09:51:49 INFO [2014/02/20 09:51:48] [.d..t......] (Last Modified: 2014/02/19-15:51:34) (bytes: 0         ) ./
2014/02/20 09:51:49 INFO [2014/02/20 09:51:48] [>f+++++++++] (Last Modified: 2014/02/19-15:51:33) (bytes: 27981892  ) somefile.zip
      27.98M 100%   82.27MB/s    0:00:00 (xfer#1, to-check=0/2) 0
2014/02/20 09:51:49 INFO total: matches=0  hash_hits=0  false_alarms=0 data=27981892 
2014/02/20 09:51:49 INFO  
2014/02/20 09:51:49 INFO rsync[25205] (sender) heap statistics: 
2014/02/20 09:51:49 INFO   arena:        1060864   (bytes from sbrk) 
2014/02/20 09:51:49 INFO   ordblks:            1   (chunks not in use) 
2014/02/20 09:51:49 INFO   smblks:             4 
2014/02/20 09:51:49 INFO   hblks:              1   (chunks from mmap) 
2014/02/20 09:51:49 INFO   hblkhd:        135168   (bytes from mmap) 
2014/02/20 09:51:49 INFO   allmem:       1196032   (bytes from sbrk + mmap) 
2014/02/20 09:51:49 INFO   usmblks:            0 
2014/02/20 09:51:49 INFO   fsmblks:          304 
2014/02/20 09:51:49 INFO   uordblks:      667008   (bytes used) 
2014/02/20 09:51:49 INFO   fordblks:      393856   (bytes free) 
2014/02/20 09:51:49 INFO   keepcost:      393552   (bytes in releasable chunk) 
2014/02/20 09:51:49 INFO  
2014/02/20 09:51:49 INFO rsync[25207] (server receiver) heap statistics: 
2014/02/20 09:51:49 INFO   arena:         286720   (bytes from sbrk) 
2014/02/20 09:51:49 INFO   ordblks:            2   (chunks not in use) 
2014/02/20 09:51:49 INFO   smblks:             3 
2014/02/20 09:51:49 INFO   hblks:              3   (chunks from mmap) 
2014/02/20 09:51:49 INFO   hblkhd:        667648   (bytes from mmap) 
2014/02/20 09:51:49 INFO   allmem:        954368   (bytes from sbrk + mmap) 
2014/02/20 09:51:49 INFO   usmblks:            0 
2014/02/20 09:51:49 INFO   fsmblks:          224 
2014/02/20 09:51:49 INFO   uordblks:      174480   (bytes used) 
2014/02/20 09:51:49 INFO   fordblks:      112240   (bytes free) 
2014/02/20 09:51:49 INFO   keepcost:      102352   (bytes in releasable chunk) 
2014/02/20 09:51:49 INFO  
2014/02/20 09:51:49 INFO rsync[25206] (server generator) heap statistics: 
2014/02/20 09:51:49 INFO   arena:         135168   (bytes from sbrk) 
2014/02/20 09:51:49 INFO   ordblks:            2   (chunks not in use) 
2014/02/20 09:51:49 INFO   smblks:             6 
2014/02/20 09:51:49 INFO   hblks:              2   (chunks from mmap) 
2014/02/20 09:51:49 INFO   hblkhd:        401408   (bytes from mmap) 
2014/02/20 09:51:49 INFO   allmem:        536576   (bytes from sbrk + mmap) 
2014/02/20 09:51:49 INFO   usmblks:            0 
2014/02/20 09:51:49 INFO   fsmblks:          400 
2014/02/20 09:51:49 INFO   uordblks:       82960   (bytes used) 
2014/02/20 09:51:49 INFO   fordblks:       52208   (bytes free) 
2014/02/20 09:51:49 INFO   keepcost:       32816   (bytes in releasable chunk) 
2014/02/20 09:51:49 INFO  
2014/02/20 09:51:49 INFO Number of files: 2 
2014/02/20 09:51:49 INFO Number of files transferred: 1 
2014/02/20 09:51:49 INFO Total file size: 27.98M bytes 
2014/02/20 09:51:49 INFO Total transferred file size: 27.98M bytes 
2014/02/20 09:51:49 INFO Literal data: 27.98M bytes 
2014/02/20 09:51:49 INFO Matched data: 0 bytes 
2014/02/20 09:51:49 INFO File list size: 93 
2014/02/20 09:51:49 INFO File list generation time: 1.277 seconds 
2014/02/20 09:51:49 INFO File list transfer time: 0.000 seconds 
2014/02/20 09:51:49 INFO Total bytes sent: 27.99M 
2014/02/20 09:51:49 INFO Total bytes received: 34 
2014/02/20 09:51:49 INFO  
2014/02/20 09:51:49 INFO sent 27.99M bytes  received 34 bytes  11.20M bytes/sec 
2014/02/20 09:51:49 INFO total size is 27.98M  speedup is 1.00 

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .