【问题标题】:How to restore Bitbucket Backup using SCM Backup?如何使用 SCM Backup 恢复 Bitbucket Backup?
【发布时间】:2021-10-07 16:27:06
【问题描述】:

我最近尝试使用 SCM Backup 备份我的 BitBucket 存储库。这是我所做的:

在我的 MacOS 上安装了 dot net

已安装 SCM 备份

我在 BitBucket 中为 SCM 备份创建了应用密码。

我在 settings.yml 文件中做了如下改动:

# all backups go here
localFolder: 'c:\scm-backup'

# when an error occurs, wait that many seconds before exiting the application
waitSecondsOnError: 5

# uncomment this to send SCM Backup's console output via email
#email:
#  from: from@example.com
#  to: to@example.com
#  server: smtp.example.com
#  port: 0
#  useSsl: false
#  userName: testuser
#  password: not-the-real-password

sources:

  - title:  bitbucket_bkp
    hoster: bitbucket
    type: org
    name: my_username
    authName: my_username
    password: App Password that I created

现在当我跑步时 -

dotnet ScmBackup.dll

它给出了输出 -

SCM Backup 1.2.1.552abf5
https://scm-backup.org/
Backing up config files
Getting repositories for source 'bitbucket_bkp' from hoster 'bitbucket'
Trying to find SCMs on this machine...
Backing up source: bitbucket_bkp
Backup finished!
The backups are in this directory: c:\scm-backup

如何从这个 c:\scm-backup 文件恢复存储库?

我对此一无所知。

根据文档bitbucket-scm-backup,当我在设置字段的名称字段中给出团队名称时,它会给出以下错误:

SCM Backup 1.2.1.552abf5
https://scm-backup.org/
Backing up config files
Getting repositories for source 'bitbucket_bkp' from hoster 'bitbucket'
User my_team_name not found!
Backup failed!
The application will close in 5 seconds!

我想备份我团队在 BitBucket 中的所有存储库并恢复它?

我该怎么办?

根据 Chris 的建议,我在 settings.yml 文件中进行了以下更改 -

# all backups go here
localFolder: '/Users/rahman/Desktop/'

现在,当我进行备份时,我的桌面上会出现一个名为 bitbucket_bkp 的文件夹。但它是空的。如何恢复?

另外,如何通过指定团队名称来备份整个团队?它不适合我。

为了支持我的团队,我对设置文件进行了如下更改 -

# all backups go here
localFolder: '/Users/rahman/Desktop/riz_bkp/'

# when an error occurs, wait that many seconds before exiting the application
waitSecondsOnError: 5

# uncomment this to send SCM Backup's console output via email
#email:
#  from: from@example.com
#  to: to@example.com
#  server: smtp.example.com
#  port: 0
#  useSsl: false
#  userName: testuser
#  password: not-the-real-password

sources:

  - title:  bitbucket_bkp
    hoster: bitbucket
    type: org
    name: team_name

现在我得到了错误-

SCM Backup 1.2.1.552abf5
https://scm-backup.org/
bitbucket_bkp: AuthName and Password are empty. Without authentication, SCM Backup will backup public repositories only!
Backing up config files
Getting repositories for source 'bitbucket_bkp' from hoster 'bitbucket'
User team_name not found!
Backup failed!
The application will close in 5 seconds!

怎么办?

【问题讨论】:

    标签: bitbucket backup restore


    【解决方案1】:

    问题 1:“如何从这个 c:\scm-backup 文件恢复存储库?”

    很高兴听到 SCM 备份可在 MacOS 上运行,但请在 System Requirements 中注明这一点:

    到目前为止,SCM Backup 仅在 Windows 上编写和测试。从技术上讲,它应该也可以在 Linux 和 MacOS 上运行,但这还没有经过测试。

    我在 Windows 上,c:\scm-backup 是 Windows 上的有效文件夹/目录,但可能不适用于 Mac。
    c:是Windows系统盘)

    我无法使用 Mac,所以我无法测试任何东西...但根据我刚刚搜索的内容,您应该使用类似 /Users/your_user/Documents/scm-backup 的路径。

    该路径应该已经存在,并且运行 SCM 备份的用户应该对其具有写入权限。
    如果您可以确认这可行,我会将其添加到文档中。

    关于恢复:

    你可能读过the documentation about restoring。那里描述了如何进行实际还原的技术步骤,但现在缺少的是对本地文件夹内容的描述。

    我会将其添加到文档中,但这是简短版本:

    localFolderc:\scm-backup 更改为适用于MacOS 的任何内容后,运行SCM 备份,该文件夹应包含每个source defined in the config 的一个子文件夹。所以在你的情况下,它应该被命名为bitbucket_bkp

    在里面,每个存储库都有一个子文件夹,在那个里面,至少有一个子文件夹repo(如果该repo 有一个wiki,可能还有另一个名为wiki)。 p>

    repo 文件夹包含您从 Bitbucket 中的存储库的完整克隆,这是 the documentation about restoring 所指的“本地存储库”。


    问题2:当你尝试备份一个团队时,备份出错

    请看the docs about sources in the configuration:

    每个来源必须至少具有这四个属性:

    [...]

    type

    userorg,具体取决于您要备份用户还是组织。

    name

    您要备份的用户/组织的名称。

    所以它是:

    type: user
    name: my_username
    

    或:

    type: org
    name: my_team_name 
    

    在您发布的示例配置中,它是两者的混合。

    【讨论】:

    • 嗨。我对 settings.yml 文件进行了一些更改。我将本地文件夹指定为 /User/rahman/Desktop。现在我在备份后有一个名为 bitbucket_bkp 的文件夹,但该文件夹是空的!我该如何恢复? type:org 也不适合我吗?你能指定如何使用团队备份选项吗?
    • 如果输出看起来仍然像您在问题中发布的那样,那么我怀疑您的团队没有任何存储库。需要说明的是:SCM Backup 尝试备份团队 (https://bitbucket.org/my_team_name/repo_name) 的存储库,不是团队成员用户的存储库!!
    • 嘿@Christian。我再次更改了设置文件。它只有类型:组织和名称:团队名称。现在我收到错误 - 未找到用户 团队名称。可能是什么原因?
    • 如果您的团队是私有的,您还需要设置authNamepassword。 SCM Backup 使用 Bitbucket API 来获取团队存储库的列表,并且当 API 返回 404 时会显示特定的错误消息......这可能是因为 API 根本不会为没有身份验证的私人团队返回任何内容.
    • 嘿@Christian。我终于能够确定问题所在。现在运行良好。非常感谢!
    【解决方案2】:

    MacOS 上的 SCM 备份和 Docker 桌面

    (我使用了来自https://community.atlassian.com/t5/Bitbucket-questions/How-to-backup-the-Bitbucket-on-cloud/qaq-p/428076 的 Rori Stumpf 的评论并添加了 DOTNET_SKIP_FIRST_TIME_EXPERIENCE 并更新了版本)

    Dockerfile
    

    内容:

    #   1. Install Docker
    #
    #   2. Copy the contents of this file to a file called 'Dockerfile'
    #
    #   3. Create settings.yml -- see https://docs.scm-backup.org/en/latest/config-bitbucket/#authentication
    #
    #   4. Build Docker Image:
    #
    #       docker build -t scm-backup .
    #
    #   5. Run the backup with output to ./bitbucket-backups:
    #
    #       docker run -t --mount src=`pwd`/bitbucket-backups,target=/scm-backup-out,type=bind scm-backup
    #
    
    FROM ubuntu:18.04
    
    ENV DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true
    
    WORKDIR /scm-backup
    
    # Install .NET core and SCM Backup
    RUN apt-get update && apt-get -y install software-properties-common && \
        add-apt-repository universe && apt-get update && \
        apt-get -y install sudo wget unzip apt-transport-https git && \
        wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb && \
        dpkg -i packages-microsoft-prod.deb && rm packages-microsoft-prod.deb && \
        apt-get update && \
        apt-get -y install dotnet-sdk-3.1 && \
        wget https://github.com/christianspecht/scm-backup/releases/download/1.4.0/scm-backup-1.4.0.ae7edc3.zip && \
        unzip scm-backup-1.4.0.ae7edc3.zip
    
    # Copy settings.yml from local filesystem to the container (rebuild every time settings.yml is updated)
    COPY settings.yml .
    
    # Run the backup
    ENTRYPOINT dotnet ScmBackup.dll
    

    settings.yml
    

    内容:

    localFolder: '/scm-backup-out'
    
    sources:
      - title: git_backup_from_bitbucket
        hoster: bitbucket
        type: org
        name: team_or_workspace_name_here
        authName: username_here_not_email_address
        password: app_password_here
    

    文件夹结构:

    bitbucket-backups
    Dockerfile
    settings.yml
    

    用法:

    docker build -t scm-backup .
    
    docker run -t --mount src=`pwd`/bitbucket-backups,target=/scm-backup-out,type=bind scm-backup
    

    【讨论】:

      猜你喜欢
      • 2021-06-26
      • 2022-12-01
      • 2021-12-12
      • 1970-01-01
      • 2015-11-05
      • 2013-03-03
      • 2014-01-07
      • 2013-08-20
      • 1970-01-01
      相关资源
      最近更新 更多