rsync e permissões de arquivo - linux

2

Estou tentando usar o rsync para copiar um conjunto de arquivos de um sistema para outro. Estou executando o comando como um usuário normal (não root). No sistema remoto, os arquivos são de propriedade do Apache e, quando copiados, eles obviamente pertencem à conta local (fred).

Meu problema é que toda vez que eu executo o comando rsync, todos os arquivos são re-sincronizados, mesmo que eles não tenham mudado. Eu acho que o problema é que o rsync vê os donos dos arquivos diferentes e meu usuário local não tem a capacidade de alterar a propriedade para o apache, mas eu não estou incluindo as opções -a ou -o então eu pensei que isso não ser verificado. Se eu executar o comando como root, os arquivos virão de propriedade do apache e não virão uma segunda vez se eu executar o comando novamente. No entanto, não posso executar isso como root por outros motivos. Aqui está o comando:

/usr/bin/rsync --recursive --rsh=/usr/bin/ssh --rsync-path=/usr/bin/rsync --verbose [email protected]:/src/dir/ /local/dir
    
por Fred Snertz 03.05.2011 / 01:43

1 resposta

3

Eis a resposta para o seu problema:

-c, --checksum
      This changes the way rsync checks if the files have been changed and are in need of a  transfer.   Without  this  option,
      rsync  uses  a "quick check" that (by default) checks if each file's size and time of last modification match between the
      sender and receiver.  This option changes this to compare a 128-bit checksum for each file  that  has  a  matching  size.
      Generating  the  checksums  means  that both sides will expend a lot of disk I/O reading all the data in the files in the
      transfer (and this is prior to any reading that will be done to transfer changed files), so this  can  slow  things  down
      significantly.

      The  sending  side  generates  its checksums while it is doing the file-system scan that builds the list of the available
      files.  The receiver generates its checksums when it is scanning for changed files, and will checksum any file  that  has
      the  same  size  as the corresponding sender's file:  files with either a changed size or a changed checksum are selected
      for transfer.

      Note that rsync always verifies that each transferred file was correctly reconstructed on the receiving side by  checking
      a  whole-file  checksum  that is generated as the file is transferred, but that automatic after-the-transfer verification
      has nothing to do with this option's before-the-transfer "Does this file need to be updated?" check.

      For protocol 30 and beyond (first supported in 3.0.0), the checksum used is MD5.  For older protocols, the checksum  used
      is MD4.

Então corra:

/usr/bin/rsync -c --recursive --rsh=/usr/bin/ssh --rsync-path=/usr/bin/rsync --verbose [email protected]:/src/dir/ /local/dir

Note que pode haver uma troca de time + disk churn usando essa opção. Pessoalmente, eu provavelmente só iria sincronizar os tempos do arquivo também:

/usr/bin/rsync -t --recursive --rsh=/usr/bin/ssh --rsync-path=/usr/bin/rsync --verbose [email protected]:/src/dir/ /local/dir
    
por 03.05.2011 / 19:48

Tags