口是心非:在目录名称中使用空格进行还原
Duplicity: Restore with spaces in directory names
我正在尝试使用口是心非的包装脚本 (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 [=10=] <date> <file> <restore-to>"; exit; fi
duplicity \
--encrypt-key=${GPG_KEY} \
--sign-key=${GPG_KEY} \
--file-to-restore \
--restore-time \
${DEST}
# Reset the ENV variables. Don't need them sitting around
export AWS_ACCESS_KEY_ID=
export AWS_SECRET_ACCESS_KEY=
export PASSPHRASE=
我无法恢复存储在名称中带有 space 的目录中的文件。我尝试了以下方法:
没有引号或转义斜线:
./duplicity-restore.sh "2018-02-08" dir1/dir2/dir name with spaces/filename.txt /destination/
以上导致错误 "dir1/dir2/dir not found in archive - no files restored."
引用整个路径参数:
./duplicity-restore.sh "2018-02-08" "dir1/dir2/dir name with spaces/filename.txt" /destination/
以上导致错误 "Expected 2 args, got 15"
仅引用名称中包含 space 的目录:
./duplicity-restore.sh "2018-02-08" dir1/dir2/'dir name with spaces'/filename.txt
以上导致错误 "Expected 2 args, got 15"
转义目录名称中每个 space 旁边的斜杠:
./duplicity-restore.sh "2018-02-08" dir1/dir2/dir\ name\ with\ spaces/filename.txt /destination/
以上导致错误 "Expected 2 args, got 15"
看来,无论我如何尝试转义目录名称中的 space,Duplicity 都会将每个 space 视为一个单独的参数。我要恢复的文件有几个目录,所有目录的名称中都包含 spaces。
Duplicity 版本为 0.7.17,运行 在 CentOS 7 上并备份到 Amazon S3 存储桶。
这是包装 shell 脚本中的一个错误,而不是口是心非。如果您希望将一个论点视为一个论点,则必须将其重新用引号引起来。
duplicity ... --file-to-restore "" ...
..ede/duply.net
我正在尝试使用口是心非的包装脚本 (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 [=10=] <date> <file> <restore-to>"; exit; fi
duplicity \
--encrypt-key=${GPG_KEY} \
--sign-key=${GPG_KEY} \
--file-to-restore \
--restore-time \
${DEST}
# Reset the ENV variables. Don't need them sitting around
export AWS_ACCESS_KEY_ID=
export AWS_SECRET_ACCESS_KEY=
export PASSPHRASE=
我无法恢复存储在名称中带有 space 的目录中的文件。我尝试了以下方法:
没有引号或转义斜线:
./duplicity-restore.sh "2018-02-08" dir1/dir2/dir name with spaces/filename.txt /destination/
以上导致错误 "dir1/dir2/dir not found in archive - no files restored."
引用整个路径参数:
./duplicity-restore.sh "2018-02-08" "dir1/dir2/dir name with spaces/filename.txt" /destination/
以上导致错误 "Expected 2 args, got 15"
仅引用名称中包含 space 的目录:
./duplicity-restore.sh "2018-02-08" dir1/dir2/'dir name with spaces'/filename.txt
以上导致错误 "Expected 2 args, got 15"
转义目录名称中每个 space 旁边的斜杠:
./duplicity-restore.sh "2018-02-08" dir1/dir2/dir\ name\ with\ spaces/filename.txt /destination/
以上导致错误 "Expected 2 args, got 15"
看来,无论我如何尝试转义目录名称中的 space,Duplicity 都会将每个 space 视为一个单独的参数。我要恢复的文件有几个目录,所有目录的名称中都包含 spaces。
Duplicity 版本为 0.7.17,运行 在 CentOS 7 上并备份到 Amazon S3 存储桶。
这是包装 shell 脚本中的一个错误,而不是口是心非。如果您希望将一个论点视为一个论点,则必须将其重新用引号引起来。
duplicity ... --file-to-restore "" ...
..ede/duply.net