Search code examples
bitbucketbackuprestore

How to restore Bitbucket Backup using SCM Backup?


I recently tried to take a backup of my BitBucket repositories using SCM Backup. Here is what I did:

Installed dot net on my MacOS

Installed SCM Backup

I created an App Password for SCM Backup in BitBucket.

I made the following changes in the settings.yml file:

# 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

Now when I run -

dotnet ScmBackup.dll

It gives the output -

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

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

I am clueless about it.

Also as per the documentation bitbucket-scm-backup when I give the team name in the name field in the setting field it gives the below error:

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!

I want to take the backup of all the repositories of my team in BitBucket and restore it ?

What should I do ?

As per Chris suggestion I made the following changes in the settings.yml file -

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

Now when I take the backup I get a folder called bitbucket_bkp in my Desktop. But it is empty. How do I restore it?

Also how can I take the backup of the entire team by specifying the team name? It is not working for me.

To take the backup of my team I have made changes to the settings file like this -

# 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

Now I get the error-

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!

What to do ?


Solution

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

    Glad to hear that SCM Backup works on MacOS, but please note this in the 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.

    I'm on Windows, and c:\scm-backup is a valid folder/directory on Windows, but will probably not work on a Mac.
    (c: is the system drive on Windows)

    I don't have access to a Mac, so I can't test anything...but according to what I just googled, you should use a path like /Users/your_user/Documents/scm-backup.

    The path should already exist, and the user which is running SCM Backup should have write access to it.
    If you can confirm that this works, I'll add it to the docs.

    Concerning restores:

    You probably read the documentation about restoring. The technical steps how to do the actual restore are described there, but what's missing right now is the description how the content of the local folder.

    I'll add that to the documentation, but here's the short version:

    After changing localFolder from c:\scm-backup to whatever works on MacOS, run SCM Backup and the folder should contain one subfolder per source defined in the config. So in your case, it should be named bitbucket_bkp.

    Inside, there's one subfolder for each repository, and inside that, there's at least one subfolder repo (and maybe another named wiki, if that repo has a wiki).

    This repo folder contains a full clone of your repository from Bitbucket, and this is the "local repository" that the documentation about restoring refers to.


    Question 2: The backup gives an error when you try to backup a team

    Please see 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.

    So it's either:

    type: user
    name: my_username
    

    or:

    type: org
    name: my_team_name 
    

    In the example config you posted, it's a mixture of both.