从Google Cloud SDK接收“错误字符范围”错误

时间:2019-12-22 23:33:26

标签: google-app-engine google-cloud-platform google-cloud-storage

所以我试图将自动备份添加到我的Minecraft服务器,并且我正在使用bash脚本,该脚本可以自动保存世界并将其保存在云存储中。每当我运行脚本时,都会出现此错误:

引发错误,v#表达式无效 sre_constants.error:字符范围错误

在听说这是Python 2.7问题后,我已经安装了Python 3,并且脚本始终以相同的错误运行2.7。

Python版本:2.7.13(使用)和3.5.3。 Debian Linux

bash脚本:

#!/bin/bash
screen -r mcs -X stuff '/save-all\n/save-off\n'
/usr/bin/gsutil cp -R ${BASH_SOURCE%/*}/world gs://[terits-smp-minecraft-minecraft-backup]/$(date "+%Y%m%d-%H%M%S")-world
screen -r mcs -X stuff '/save-on\n'

完整的调试日志:

Traceback (most recent call last):
  File "/usr/lib/google-cloud-sdk/platform/gsutil/gsutil", line 21, in <module>
    gsutil.RunMain()
  File "/usr/lib/google-cloud-sdk/platform/gsutil/gsutil.py", line 124, in RunMain
    sys.exit(gslib.__main__.main())
  File "/usr/lib/google-cloud-sdk/platform/gsutil/gslib/__main__.py", line 433, in main
    user_project=user_project)
  File "/usr/lib/google-cloud-sdk/platform/gsutil/gslib/__main__.py", line 762, in _RunNamedCommandAndHandleExceptions
    _HandleUnknownFailure(e)
  File "/usr/lib/google-cloud-sdk/platform/gsutil/gslib/__main__.py", line 628, in _RunNamedCommandAndHandleExceptions
    user_project=user_project)
  File "/usr/lib/google-cloud-sdk/platform/gsutil/gslib/command_runner.py", line 411, in RunNamedCommand
    return_code = command_inst.RunCommand()
  File "/usr/lib/google-cloud-sdk/platform/gsutil/gslib/commands/cp.py", line 1162, in RunCommand
    copy_helper_opts.daisy_chain,
  File "/usr/lib/google-cloud-sdk/platform/gsutil/gslib/name_expansion.py", line 650, in __init__
    name_expansion_dest_tuple = next(self.name_expansion_dest_iter)
  File "/usr/lib/google-cloud-sdk/platform/gsutil/gslib/commands/cp.py", line 1093, in _ConstructNameExpansionIteratorDstTupleIterator
    logger=self.logger))
  File "/usr/lib/google-cloud-sdk/platform/gsutil/gslib/utils/copy_helper.py", line 1419, in ExpandUrlToSingleBlr
    logger=logger))
  File "/usr/lib/google-cloud-sdk/platform/gsutil/gslib/wildcard_iterator.py", line 161, in __iter__
    for bucket_listing_ref in self._ExpandBucketWildcards(bucket_fields=['id']):
  File "/usr/lib/google-cloud-sdk/platform/gsutil/gslib/wildcard_iterator.py", line 389, in _ExpandBucketWildcards
    prog = re.compile(regex)
  File "/usr/lib/python2.7/re.py", line 194, in compile
    return _compile(pattern, flags)
  File "/usr/lib/python2.7/re.py", line 251, in _compile
    raise error, v # invalid expression
sre_constants.error: bad character range

到目前为止,我一直在使用本指南为我提供帮助,因为我不太了解Google Cloud: https://cloud.google.com/solutions/gaming/minecraft-server#schedule_backups

1 个答案:

答案 0 :(得分:0)

此错误raise error, v # invalid expression由gsutil触发。这是因为您未遵循Make R Studio plots only show up in new window

这部分无效$(date "+%Y%m%d-%H%M%S"),因为您使用的是gsutil实际使用的通配符,并且您还会在名称中留下不被接受的空格。

我建议您在批处理的另一步骤中获取日期和时间,然后将其作为字符串直接添加到gsutil命令中。