-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.py
More file actions
35 lines (27 loc) · 1.17 KB
/
main.py
File metadata and controls
35 lines (27 loc) · 1.17 KB
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
35
import os
from pathlib import Path
from github_backup import GithubBackup
from utils import create_logger
if __name__ == "__main__":
logger = create_logger("github-backup")
# Parse environment variables
logger.info("Parsing environment variables")
username = os.getenv("GITHUB_USERNAME", "")
if username == "":
logger.error("You must provide a GITHUB_USERNAME environment variable!")
exit(1)
access_token = os.getenv("GITHUB_ACCESS_TOKEN", "")
if access_token == "":
logger.error("You must provide a GITHUB_ACCESS_TOKEN environment variable!")
exit(1)
destination_dir = os.getenv("DESTINATION_DIR", "/backups")
destination_dir = Path(destination_dir)
if not destination_dir.exists():
logger.error("Destination directory does not exist!")
exit(1)
exclude_repos_list = os.getenv("EXCLUDE_REPOS_LIST", "").split(",")
exclude_forks = os.getenv("EXCLUDE_FORKS", "False") != "False"
github_backup = GithubBackup(username, access_token, exclude_repos_list, exclude_forks)
logger.info("Starting backup")
github_backup.backup(destination_dir)
logger.info("Backup successfully finished!")