mirror of
https://github.com/josegonzalez/python-github-backup.git
synced 2025-12-05 16:18:02 +01:00
Add option to fetch followers/following JSON data
This commit is contained in:
24
README.rst
24
README.rst
@@ -28,12 +28,12 @@ Usage
|
|||||||
CLI Usage is as follows::
|
CLI Usage is as follows::
|
||||||
|
|
||||||
github-backup [-h] [-u USERNAME] [-p PASSWORD] [-t TOKEN]
|
github-backup [-h] [-u USERNAME] [-p PASSWORD] [-t TOKEN]
|
||||||
[-o OUTPUT_DIRECTORY] [-i] [--starred] [--watched]
|
[-o OUTPUT_DIRECTORY] [-i] [--starred] [--all-starred]
|
||||||
[--all] [--issues] [--issue-comments] [--issue-events]
|
[--watched] [--followers] [--following] [--all]
|
||||||
[--pulls] [--pull-comments] [--pull-commits] [--labels]
|
[--issues] [--issue-comments] [--issue-events] [--pulls]
|
||||||
[--hooks] [--milestones] [--repositories] [--bare] [--lfs]
|
[--pull-comments] [--pull-commits] [--labels] [--hooks]
|
||||||
[--wikis] [--skip-existing] [--all-starred]
|
[--milestones] [--repositories] [--bare] [--lfs]
|
||||||
[--gists] [--starred-gists]
|
[--wikis] [--gists] [--starred-gists] [--skip-existing]
|
||||||
[-L [LANGUAGES [LANGUAGES ...]]] [-N NAME_REGEX]
|
[-L [LANGUAGES [LANGUAGES ...]]] [-N NAME_REGEX]
|
||||||
[-H GITHUB_HOST] [-O] [-R REPOSITORY] [-P] [-F]
|
[-H GITHUB_HOST] [-O] [-R REPOSITORY] [-P] [-F]
|
||||||
[--prefer-ssh] [-v]
|
[--prefer-ssh] [-v]
|
||||||
@@ -54,12 +54,16 @@ CLI Usage is as follows::
|
|||||||
password for basic auth. If a username is given but
|
password for basic auth. If a username is given but
|
||||||
not a password, the password will be prompted for.
|
not a password, the password will be prompted for.
|
||||||
-t TOKEN, --token TOKEN
|
-t TOKEN, --token TOKEN
|
||||||
personal access or OAuth token
|
personal access or OAuth token, or path to token
|
||||||
|
(file://...)
|
||||||
-o OUTPUT_DIRECTORY, --output-directory OUTPUT_DIRECTORY
|
-o OUTPUT_DIRECTORY, --output-directory OUTPUT_DIRECTORY
|
||||||
directory at which to backup the repositories
|
directory at which to backup the repositories
|
||||||
-i, --incremental incremental backup
|
-i, --incremental incremental backup
|
||||||
--starred include JSON output of starred repositories in backup
|
--starred include JSON output of starred repositories in backup
|
||||||
|
--all-starred include starred repositories in backup
|
||||||
--watched include watched repositories in backup
|
--watched include watched repositories in backup
|
||||||
|
--followers include JSON output of followers in backup
|
||||||
|
--following include JSON output of following users in backup
|
||||||
--all include everything in backup
|
--all include everything in backup
|
||||||
--issues include issues in backup
|
--issues include issues in backup
|
||||||
--issue-comments include issue comments in backup
|
--issue-comments include issue comments in backup
|
||||||
@@ -73,12 +77,12 @@ CLI Usage is as follows::
|
|||||||
--milestones include milestones in backup
|
--milestones include milestones in backup
|
||||||
--repositories include repository clone in backup
|
--repositories include repository clone in backup
|
||||||
--bare clone bare repositories
|
--bare clone bare repositories
|
||||||
--lfs clone LFS repositories (requires Git LFS to be installed, https://git-lfs.github.com)
|
--lfs clone LFS repositories (requires Git LFS to be
|
||||||
|
installed, https://git-lfs.github.com)
|
||||||
--wikis include wiki clone in backup
|
--wikis include wiki clone in backup
|
||||||
--skip-existing skip project if a backup directory exists
|
|
||||||
--all-starred include starred repositories in backup
|
|
||||||
--gists include gists in backup
|
--gists include gists in backup
|
||||||
--starred-gists include starred gists in backup
|
--starred-gists include starred gists in backup
|
||||||
|
--skip-existing skip project if a backup directory exists
|
||||||
-L [LANGUAGES [LANGUAGES ...]], --languages [LANGUAGES [LANGUAGES ...]]
|
-L [LANGUAGES [LANGUAGES ...]], --languages [LANGUAGES [LANGUAGES ...]]
|
||||||
only allow these languages
|
only allow these languages
|
||||||
-N NAME_REGEX, --name-regex NAME_REGEX
|
-N NAME_REGEX, --name-regex NAME_REGEX
|
||||||
|
|||||||
@@ -168,6 +168,14 @@ def parse_args():
|
|||||||
action='store_true',
|
action='store_true',
|
||||||
dest='include_watched',
|
dest='include_watched',
|
||||||
help='include watched repositories in backup')
|
help='include watched repositories in backup')
|
||||||
|
parser.add_argument('--followers',
|
||||||
|
action='store_true',
|
||||||
|
dest='include_followers',
|
||||||
|
help='include JSON output of followers in backup')
|
||||||
|
parser.add_argument('--following',
|
||||||
|
action='store_true',
|
||||||
|
dest='include_following',
|
||||||
|
help='include JSON output of following users in backup')
|
||||||
parser.add_argument('--all',
|
parser.add_argument('--all',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
dest='include_everything',
|
dest='include_everything',
|
||||||
@@ -886,21 +894,37 @@ def backup_account(args, output_directory):
|
|||||||
account_cwd = os.path.join(output_directory, 'account')
|
account_cwd = os.path.join(output_directory, 'account')
|
||||||
|
|
||||||
if args.include_starred or args.include_everything:
|
if args.include_starred or args.include_everything:
|
||||||
output_file = '{0}/starred.json'.format(account_cwd)
|
output_file = "{0}/starred.json".format(account_cwd)
|
||||||
template = "https://{0}/users/{1}/starred"
|
template = "https://{0}/users/{1}/starred".format(get_github_api_host(args), args.user)
|
||||||
template = template.format(get_github_api_host(args), args.user)
|
|
||||||
_backup_data(args,
|
_backup_data(args,
|
||||||
'starred repositories',
|
"starred repositories",
|
||||||
template,
|
template,
|
||||||
output_file,
|
output_file,
|
||||||
account_cwd)
|
account_cwd)
|
||||||
|
|
||||||
if args.include_watched or args.include_everything:
|
if args.include_watched or args.include_everything:
|
||||||
output_file = '{0}/watched.json'.format(account_cwd)
|
output_file = "{0}/watched.json".format(account_cwd)
|
||||||
template = "https://{0}/users/{1}/subscriptions"
|
template = "https://{0}/users/{1}/subscriptions".format(get_github_api_host(args), args.user)
|
||||||
template = template.format(get_github_api_host(args), args.user)
|
|
||||||
_backup_data(args,
|
_backup_data(args,
|
||||||
'watched repositories',
|
"watched repositories",
|
||||||
|
template,
|
||||||
|
output_file,
|
||||||
|
account_cwd)
|
||||||
|
|
||||||
|
if args.include_followers or args.include_everything:
|
||||||
|
output_file = "{0}/followers.json".format(account_cwd)
|
||||||
|
template = "https://{0}/users/{1}/followers".format(get_github_api_host(args), args.user)
|
||||||
|
_backup_data(args,
|
||||||
|
"followers",
|
||||||
|
template,
|
||||||
|
output_file,
|
||||||
|
account_cwd)
|
||||||
|
|
||||||
|
if args.include_following or args.include_everything:
|
||||||
|
output_file = "{0}/following.json".format(account_cwd)
|
||||||
|
template = "https://{0}/users/{1}/following".format(get_github_api_host(args), args.user)
|
||||||
|
_backup_data(args,
|
||||||
|
"following",
|
||||||
template,
|
template,
|
||||||
output_file,
|
output_file,
|
||||||
account_cwd)
|
account_cwd)
|
||||||
|
|||||||
Reference in New Issue
Block a user