如何使用 SCM 备份恢复 Bitbucket 备份?

How to restore Bitbucket Backup using SCM Backup?

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

在我的 MacOS 上安装了 dotnet

已安装 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!

怎么办?

问题 1:"How do I restore the repositories from this c:\scm-backup file?"

很高兴听到 SCM Backup 在 MacOS 上运行,但请在 System Requirements:

中注明这一点

So far, SCM Backup has been written and tested on Windows only. Technically, it should run on Linux and MacOS as well, but this has not been tested yet.

我在 Windows,c:\scm-backup 在 Windows 上是有效的 folder/directory,但可能不适用于 Mac。
c: 是 Windows 上的系统驱动器)

我无权访问 Mac,所以我无法测试任何东西...但是根据我刚刚用谷歌搜索的结果,您应该使用像 /Users/your_user/Documents/scm-backup 这样的路径。

路径应该已经存在,运行ning SCM Backup 的用户应该有写入权限。
如果你能确认这有效,我会把它添加到文档中。

关于恢复:

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

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

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

在里面,每个存储库都有一个子文件夹,在 that 里面,至少有一个子文件夹 repo(也许还有另一个名为 wiki,如果那个 repo 有一个 wiki)。

repo 文件夹包含来自 Bitbucket 的存储库的完整克隆,这是 the documentation about restoring 所指的 "local repository"。


问题二:备份团队时备份报错

请参阅the docs about sources in the configuration:

Each source must have at least those four properties:

[...]

type

Either user or org, depending if you want to backup an user or a organization.

name

The name of the user/organization you want to backup.

所以它是:

type: user
name: my_username

或:

type: org
name: my_team_name 

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

MacOS 上的 SCM 备份和 Docker 桌面

(我使用了 Rori Stumpf 的评论:https://community.atlassian.com/t5/Bitbucket-questions/How-to-backup-the-Bitbucket-on-cloud/qaq-p/428076 并添加了 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