-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackup.py
34 lines (24 loc) · 981 Bytes
/
backup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import os
from config import private_token, repoUrlType
from functions import write_log, load_projects
write_log('Operation starting...')
write_log('*' * 30, False)
write_log('Getting the project list you can access from GitLab.')
projects = load_projects(private_token)
write_log('Your projects fetched.')
write_log('*' * 30, False)
for project in projects:
if repoUrlType == 'ssh':
projectUri = project['ssh_url_to_repo']
else:
projectUri = project['http_url_to_repo']
write_log(projectUri + ' cloning...')
targetDirectory = 'repositories/' + project['path'] + '.git'
if os.path.exists(targetDirectory):
write_log(targetDirectory + ' deleting...')
os.system('rm -rf ' + targetDirectory)
os.system('git clone --mirror --progress ' + projectUri + ' ' + targetDirectory)
write_log(targetDirectory + ' clone completed!')
write_log('*' * 30, False)
write_log('*' * 30, False)
write_log('Operation completed.')