简体   繁体   English

重复性:使用目录名称中的空格进行还原

[英]Duplicity: Restore with spaces in directory names

I'm attempting to restore a file using a duplicity wrapper script (duplicity-restore.sh), contents below: 我正在尝试使用双重包装器脚本(duplicity-restore.sh)还原文件,内容如下:

#!/bin/bash
# Export some ENV variables so you don't have to type anything
export AWS_ACCESS_KEY_ID="AWS_KEY"
export AWS_SECRET_ACCESS_KEY="AWS_Secret_key"
export PASSPHRASE="######"

# Your GPG key
GPG_KEY=######

# The destination
DEST="s3://s3.amazonaws.com/<path-to-bucket>"

if [ $# -lt 3 ]; then echo "Usage $0 <date> <file> <restore-to>"; exit; fi

duplicity \
--encrypt-key=${GPG_KEY} \
--sign-key=${GPG_KEY} \
--file-to-restore $2 \
--restore-time $1 \
${DEST} $3

# Reset the ENV variables. Don't need them sitting around
export AWS_ACCESS_KEY_ID=
export AWS_SECRET_ACCESS_KEY=
export PASSPHRASE=

I'm having difficulty restoring files that are stored in directories with spaces in their names. 我很难恢复名称中带有空格的目录中存储的文件。 I've tried the following: 我尝试了以下方法:

No quotes or escape slashes: 没有引号或斜杠:

./duplicity-restore.sh "2018-02-08" dir1/dir2/dir name with spaces/filename.txt /destination/

Above results in error "dir1/dir2/dir not found in archive - no files restored." 上述结果导致错误“在存档中找不到dir1 / dir2 / dir-没有还原文件”。

Quoting the entire path argument: 引用整个路径参数:

./duplicity-restore.sh "2018-02-08" "dir1/dir2/dir name with spaces/filename.txt" /destination/

Above results in error "Expected 2 args, got 15" 上述结果导致错误“预期2个参数,得到15个”

Quoting only the directory with spaces in the name: 仅引用名称中带有空格的目录:

./duplicity-restore.sh "2018-02-08" dir1/dir2/'dir name with spaces'/filename.txt

Above results in error "Expected 2 args, got 15" 上述结果导致错误“预期2个参数,得到15个”

Escape slashes next to each space in directory name: 目录名称中每个空格旁边的转义斜杠:

./duplicity-restore.sh "2018-02-08" dir1/dir2/dir\ name\ with\ spaces/filename.txt /destination/

Above results in error "Expected 2 args, got 15" 上述结果导致错误“预期2个参数,得到15个”

It seems that, no matter how I try to escape the spaces in my directory names, Duplicity treats each space as a separate argument. 看来,无论我如何尝试转义目录名称中的空格,Duplicity都会将每个空格视为一个单独的参数。 The file I'm trying to restore is several directories deep, and ALL of the directories contain spaces in their names. 我要还原的文件有几个目录,所有目录的名称中都包含空格。

Duplicity version is 0.7.17, running on CentOS 7 and backing up to an Amazon S3 bucket. Duplicity版本是0.7.17,在CentOS 7上运行并备份到Amazon S3存储桶。

that's a bug in your wrapper shell script, not in duplicity. 那是包装外壳脚本中的错误,而不是重复。 if you want an argument to be kept treated as one you will have to rewrap it in quotes. 如果您希望将一个参数保留为一个参数,则必须用引号将其重新包装。

duplicity ... --file-to-restore "$2" ...

..ede/duply.net ..ede / duply.net

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM