Backup Cobra is a powerful tool designed to clone repositories, generate detailed reports in Excel format, zip repositories and upload zip files to Amazon S3. It helps you keep track of your repositories, developers' activities, and various project metrics.
Backup Cobra automates the process of cloning repositories, generate detailed reports in Excel format, zip repositories and upload zip files to Amazon S3. It supports Bitbucket repositories and provides insights into developer activities, commit histories, and project configurations.
- Clone Repositories: Clone all repositories from a Bitbucket workspace using
ghorg
. - Generate Excel Reports: Create Excel reports with detailed branch information, including last commit dates, top developers, and various project metrics.
- Zip Repositories: Generate zip files for each repositories of a workspace.
- Upload to AmazonS3: Upload a zip files, repositories of a project into amazon S3.
-
Clone the repository :
git clone https://github.com/yourusername/backup-cobra.git cd backup-cobra
-
Install Go : Make sure Go is installed. You can dowload it from the official Go website https://go.dev/doc/install
-
Install dependencies :
- ghorg (for cloning repositories)
go install github.com/gabrie30/ghorg@latest
- Excelize (for generating Excel reports)
go get -u github.com/xuri/excelize/v2
- cobra
go get -u github.com/spf13/cobra@latest
-
Install project dependencies : From the project root, run :
go mod tidy
-
Configure AWS and Bitbucket credentials : To store sensitive information like API keys or credentials, you can use a
.secrets
file. An example file namedexample.secrets
is provided in the project to help you get started.
-
Copy the
example.secrets
file and rename it to.secrets
:cp example.secrets .secrets
-
Fill it with the secrets required
-
For help to get the keys for aws amazon S3 you can use this documentation :
https://docs.aws.amazon.com/fr_fr/IAM/latest/UserGuide/id_credentials_access-keys.html
- Configure your .config file :
The
.config
file allows you to customize certain behaviors of the project. An exemple file nameexample.config
is provided in the project to help you get started.
- Copy the
example.config
file and rename it to.config
:cp example.config .config
In this .config
file you have some variables you can configurate :
-
CPU : you can choose the number of processors you want to use (by default 1).
-
DEVELOPERS_MAP : For developpers it will group some username, exemple : "DEVELOPERS_MAP=Jean D=Jean Dupont;"
-
DEFAULT_COLUMN : The list of the default column that the program do
-
TERMS_TO_SEARCH : List of terms you want to search for in the files of the repository (handle regex)
-
FILES_TO_SEARCH : List of file you want to search for in a repository (handle regex)
./backupcobra clone --dir-path <path where to clone the repositories>
./backupcobra report --dir-path <path where the repositories were cloned>
./backupcobra zip --dir-path <path where the repositories were cloned>
./backupcobra upload --dir-path <path where the repositories were cloned>
- Repositories Cloning : Clones repositories form a specified workspace.
- Excel Report Generation : Creates an Excel file with detailed information about repositories, branches, commit, etc.
- Directory Compression : Creates zip files for specified directories.
- Amazon S3 upload : Uploads directories or zip files to a secure S3 bucket.
-
cmd/ : Contains the project's CLI commands.
-
processrepos/ : Main application logic.
-
utils/ : some useful functions
Main author : Louise Calvez