Windows | Linux | macOS
NEW:
I've added a PowerShell and bash script that you can use to schedule the backup process. You can find it in the `Scripts` folder.
gitBackup is a command-line tool that allows you to create backups of a list of repositories in a specified drive or folder. The tool checks if there is an existing repository in the specified folder and updates it. If there is no repository, the tool clones it, otherwise, it pull the latest changes and updates the repository.
NOTE: You must have the necessary permissions to clone the repositories.
-
Clone or download a copy of this repository.
-
Rename the file
appsettings.tmp.jsontoappsettings.json. -
Open the
appsettings.jsonfile and configure the following:- BackupFolder: Set this to the folder where you want the backups to be stored.
- Repositories: Add the list of repositories you want to back up.
Here's an example of the appsettings.json file:
{
"AppSettings": {
"BackupFolder": "C:\\\\GitBackup\\"
},
"Repositories": [
{
"Name": "MyRepo1",
"Path": "MyRepo1",
"URL": "https://github.com/mcNets/MyRepo1"
},
{
"Name": "Osmo",
"Path": "Osmo",
"URL": "https://company.visualstudio.com/MyRepo2/_git/MyRepo2"
}
]
}- BackupFolder: The directory where backups will be stored.
- Repositories: A list of repositories to be backed up.
- Name: A friendly name for the repository.
- Path: The folder where the repository will be saved (e.g.,
BackupFolder+Path=RepositoryFolder). - URL: The repository’s URL.
- Run the command
.\gitBackup.exein the project's root directory to start the backup process.
Grant write permissions to the folder where you want to store the backups. You can do this with the following command:
sudo chmod -R 777 /path/to/your/folderIf you're using Linux, you can build the project with the following command:
dotnet publish -c Release -r linux-x64Make sure the file has execution permissions. You can grant these permissions with:
chmod +x gitBackupAfter building, run the tool with:
./gitBackupOpen an issue if you have any problem.