AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • Início
  • system&network
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • Início
  • system&network
    • Recentes
    • Highest score
    • tags
  • Ubuntu
    • Recentes
    • Highest score
    • tags
  • Unix
    • Recentes
    • tags
  • DBA
    • Recentes
    • tags
  • Computer
    • Recentes
    • tags
  • Coding
    • Recentes
    • tags
Início / unix / Perguntas / 740532
Accepted
Ole Tange
Ole Tange
Asked: 2023-03-22 06:10:14 +0800 CST2023-03-22 06:10:14 +0800 CST 2023-03-22 06:10:14 +0800 CST

rsync o arquivo `a`b

  • 772

Sim, eu sei o que você está pensando: "Quem diabos nomeia seu arquivo `a`b?"

Mas vamos supor que você tenha um arquivo chamado `a`b(possivelmente feito por um usuário maluco do Mac - obviamente não por você), e você deseja rsyncisso. A solução óbvia:

rsync server:'./`a`b' ./.;
rsync 'server:./`a`b' ./.;

dá:

bash: line 1: a: command not found
rsync: [sender] link_stat "/home/tange/b" failed: No such file or directory (2)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1865) [Receiver=3.2.7]
rsync: [Receiver] write error: Broken pipe (32)

Até:

$ rsync 'server:./\`a\`b' ./.;
bash: line 3: a\: command not found
rsync: [sender] link_stat "/home/tange/\b" failed: No such file or directory (2)
:

Qual é o rsynccomando que devo executar?

$ rsync --version
rsync  version 3.2.7  protocol version 31
rsync
  • 3 3 respostas
  • 1557 Views

3 respostas

  • Voted
  1. Best Answer
    Chris Down
    2023-03-22T07:29:53+08:002023-03-22T07:29:53+08:00

    Tendo dividido manualmente, este é um bug no rsync e foi corrigido pelo commit 5c93dedf4538 ("Add backtick to SHELL_CHARS.") , que estará no próximo rsync 3.2.8 (ainda não lançado). Ele foi quebrado pelo commit 6b8db0f6440b ("Adicionar um idioma de proteção de argumento usando escapes de barra invertida") , que está em 3.2.4.

    Como mitigação, --old-argsexiste uma opção para usar o antigo comportamento de análise de argumentos ( ):

    rsync --old-args 'server:./\`a\`b' .
    
    • 32
  2. Ole Tange
    2023-03-22T06:59:21+08:002023-03-22T06:59:21+08:00

    É um problema de versão. Parece não depender da versão do servidor, mas do cliente.

    Algo foi quebrado entre v3.2.3 e v3.2.7.

    OK:

    $ rsync-v3.2.3 --rsync-path=rsync-v3.2.7  'server:./\`a\`b' ./.;
    $ rsync-v3.2.3 --rsync-path=rsync-v3.2.3  'server:./\`a\`b' ./.;
    $ rsync-v3.2.3 --rsync-path=rsync-v3.2.3  server:./"'"'`a`'"'"b ./.;
    

    Falha:

    $ rsync-v3.2.7 --rsync-path=rsync-v3.2.7  'server:./\`a\`b' ./.;
    bash: line 3: a\: command not found
    rsync: [sender] link_stat "/home/tange/\b" failed: No such file or directory (2)
    $ rsync-v3.2.7 --rsync-path=rsync-v3.2.3  'server:./\`a\`b' ./.;
    bash: line 3: a\: command not found
    rsync: [sender] link_stat "/home/tange/\b" failed: No such file or directory (2)
    $ rsync-v3.2.3 --rsync-path=rsync-v3.2.3  'server:./`a`b' ./.;
    bash: line 1: a: command not found
    rsync: [sender] link_stat "/home/tange/b" failed: No such file or directory (2)
    $ rsync-v3.2.3 --rsync-path=rsync-v3.2.7  'server:./`a`b' ./.;
    bash: line 1: a: command not found
    rsync: [sender] link_stat "/home/tange/b" failed: No such file or directory (2)
    

    Mas falando sério: parece ser um desastre esperando para acontecer, que você precisa citar `duas vezes.

    Obrigado a @dhag por apontar o problema.

    Infelizmente não responde como fazer a transferência com a versão v3.2.7.

    • 12
  3. Stéphane Chazelas
    2023-03-24T22:56:25+08:002023-03-24T22:56:25+08:00

    Se você não tem que suportar versões rsyncanteriores a 3.0.0, use --secluded-argsaka -s, anteriormente conhecido como --protect-args, e então você não precisa se preocupar como os nomes dos arquivos podem ser interpretados pelo shell de login do usuário remoto (que pode ser qualquer coisa , portanto, fazer citações/escape corretamente é praticamente impossível) ao fazer rsync sobre rsh/ssh. Do manual (aqui em 3.2.7):

      --secluded-args, -s
             This  option  sends all filenames and most options to the remote
             rsync via the protocol (not the remote shell command line) which
             avoids  letting the remote shell modify them.  Wildcards are ex‐
             panded on the remote host by rsync instead of a shell.
    
             This is similar to the default backslash-escaping of  args  that
             was  added  in 3.2.4 (see --old-args) in that it prevents things
             like space splitting  and  unwanted  special-character  side-ef‐
             fects.  However, it has the drawbacks of being incompatible with
             older rsync versions (prior to 3.0.0) and of  being  refused  by
             restricted shells that want to be able to inspect all the option
             values for safety.
    
             This option is useful for those times that you  need  the  argu‐
             ment's character set to be converted for the remote host, if the
             remote shell is incompatible with the default backslash-escpaing
             method, or there is some other reason that you want the majority
             of the options and arguments to bypass the command-line  of  the
             remote shell.
    
             If you combine this option with --iconv, the args related to the
             remote side will be translated from  the  local  to  the  remote
             character-set.   The  translation  happens before wild-cards are
             expanded.  See also the --files-from option.
    
             You may also control this setting via the RSYNC_PROTECT_ARGS en‐
             vironment  variable.   If  it has a non-zero value, this setting
             will be enabled by default, otherwise it will be disabled by de‐
             fault.  Either state is overridden by a manually specified posi‐
             tive or negative version of this option (note  that  --no-s  and
             --no-secluded-args are the negative versions).  This environment
             variable is also superseded by a non-zero RSYNC_OLD_ARGS export.
    
             This option conflicts with the --old-args option.
    
             This option used to be called --protect-args (before 3.2.6)  and
             that older name can still be used (though specifying it as -s is
             always the easiest and most compatible choice).
    
    • 3

relate perguntas

  • rsync - movendo todos os arquivos JPG/jpg de um disco rígido para um único diretório com um script de shell

  • diretório tar para enviar apenas blocos modificados de arquivos

  • Como faço uma duplicata de uma árvore de diretórios com links simbólicos duplicados relativamente?

  • Problemas de exclusão de Rsync

  • rsync porta 22 e 873 uso

Sidebar

Stats

  • Perguntas 205573
  • respostas 270741
  • best respostas 135370
  • utilizador 68524
  • Highest score
  • respostas
  • Marko Smith

    Possível firmware ausente /lib/firmware/i915/* para o módulo i915

    • 3 respostas
  • Marko Smith

    Falha ao buscar o repositório de backports jessie

    • 4 respostas
  • Marko Smith

    Como exportar uma chave privada GPG e uma chave pública para um arquivo

    • 4 respostas
  • Marko Smith

    Como podemos executar um comando armazenado em uma variável?

    • 5 respostas
  • Marko Smith

    Como configurar o systemd-resolved e o systemd-networkd para usar o servidor DNS local para resolver domínios locais e o servidor DNS remoto para domínios remotos?

    • 3 respostas
  • Marko Smith

    apt-get update error no Kali Linux após a atualização do dist [duplicado]

    • 2 respostas
  • Marko Smith

    Como ver as últimas linhas x do log de serviço systemctl

    • 5 respostas
  • Marko Smith

    Nano - pule para o final do arquivo

    • 8 respostas
  • Marko Smith

    erro grub: você precisa carregar o kernel primeiro

    • 4 respostas
  • Marko Smith

    Como baixar o pacote não instalá-lo com o comando apt-get?

    • 7 respostas
  • Martin Hope
    user12345 Falha ao buscar o repositório de backports jessie 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl Por que a maioria dos exemplos do systemd contém WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky Como exportar uma chave privada GPG e uma chave pública para um arquivo 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll status systemctl mostra: "Estado: degradado" 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim Como podemos executar um comando armazenado em uma variável? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S Por que /dev/null é um arquivo? Por que sua função não é implementada como um programa simples? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 Como ver as últimas linhas x do log de serviço systemctl 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - pule para o final do arquivo 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla Por que verdadeiro e falso são tão grandes? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis Substitua a string em um arquivo de texto enorme (70 GB), uma linha 2017-12-30 06:58:33 +0800 CST

Hot tag

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • Início
  • Perguntas
    • Recentes
    • Highest score
  • tag
  • help

Footer

AskOverflow.Dev

About Us

  • About Us
  • Contact Us

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve