README.md (2389B) - raw
1 # Git Backup 2 3 Very simple script to back up all the repositories the user is member of on 4 GitLab and GitHub. 5 6 ## Prerequisites 7 8 In order to run the program, you will need `python3` and the python libraries 9 specified in the `requirements.txt` file. If you have `pip3` installed, you can 10 install the libraries with the command: 11 12 ``` 13 pip3 install -r requirements.txt 14 ``` 15 16 ## Running the program 17 18 To run the program, execute the file `git-backup.py`, you must set the 19 `TARGET_DIR` variable to the path where you want the script to store all the 20 backed up repositories. 21 22 ``` 23 python3 git-backup.py 24 ``` 25 26 ### Adding you GitLab and GitHub repositories 27 28 You will also need a GitLab and a GitHub access token and crete a file for each 29 token, with the content being only the token. You must set environment variables 30 `GITLAB_TOKEN_PATH` and `GITHUB_TOKEN_PATH` with the path of the file with each 31 token. 32 33 Finally, you must upload your ssh key to GitLab or GitHub if you have any 34 private or internal repositories. 35 36 ### Adding custom repositories 37 38 If you want to backup repositories from which you are not a member on the 39 currently supported hosts, or if you want to add repositories from other hosts, 40 you can do so creating a file with the following structure: 41 42 ```json 43 [ 44 { 45 "name":"<Repository name - for backup information>", 46 "description":"<Repository description - for backup information>", 47 "path":"<Repository path where the backup will be saved>", 48 "ssh_url":"<Repository url>", 49 "host":"<Repository host - for backup information and establishing saving directory>" 50 } 51 ] 52 ``` 53 54 You can add more than one object to the array and it will backup all of the 55 repositories. Make sure that you upload your ssh key to the hosts in case it is 56 needed for authentification. Set the environment variable 57 `CUSTOM_REPOSITORIES_PATH` to the path of the file. 58 59 ## Future updates 60 61 - [ ] More information on the output file or the terminal: how many new 62 repositories were added, how many have been deleted on the hosting 63 services. 64 - [ ] Manage what happens if history has changed in the hosting service. 65 66 ## License 67 68 The program is licensed under the GNU Affero General Public License version 3 or 69 later (available [here][agpl]). 70 71 ## Author 72 73 - **Oscar Benedito** - oscar@oscarbenedito.com 74 75 [agpl]: <https://www.gnu.org/licenses/agpl-3.0.html> "GNU Affero General Public License v3.0"