github-backup 0.55.0__py3-none-any.whl → 0.56.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
github_backup/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.55.0"
1
+ __version__ = "0.56.0"
@@ -0,0 +1,13 @@
1
+ """Allow running as: python -m github_backup"""
2
+
3
+ import sys
4
+
5
+ from github_backup.cli import main
6
+ from github_backup.github_backup import logger
7
+
8
+ if __name__ == "__main__":
9
+ try:
10
+ main()
11
+ except Exception as e:
12
+ logger.error(str(e))
13
+ sys.exit(1)
@@ -1,4 +1,5 @@
1
- #!python
1
+ #!/usr/bin/env python
2
+ """Command-line interface for github-backup."""
2
3
 
3
4
  import logging
4
5
  import os
@@ -36,6 +37,7 @@ logging.basicConfig(level=logging.INFO, handlers=[stdout_handler, stderr_handler
36
37
 
37
38
 
38
39
  def main():
40
+ """Main entry point for github-backup CLI."""
39
41
  args = parse_args()
40
42
 
41
43
  if args.private and not get_auth(args):
@@ -1038,7 +1038,7 @@ def download_attachment_file(url, path, auth, as_app=False, fine=False):
1038
1038
  bytes_downloaded += len(chunk)
1039
1039
 
1040
1040
  # Atomic rename to final location
1041
- os.rename(temp_path, path)
1041
+ os.replace(temp_path, path)
1042
1042
 
1043
1043
  metadata["size_bytes"] = bytes_downloaded
1044
1044
  metadata["success"] = True
@@ -1459,7 +1459,7 @@ def download_attachments(
1459
1459
 
1460
1460
  # Rename to add extension (already atomic from download)
1461
1461
  try:
1462
- os.rename(filepath, final_filepath)
1462
+ os.replace(filepath, final_filepath)
1463
1463
  metadata["saved_as"] = os.path.basename(final_filepath)
1464
1464
  except Exception as e:
1465
1465
  logger.warning(
@@ -1490,7 +1490,7 @@ def download_attachments(
1490
1490
  manifest_path = os.path.join(attachments_dir, "manifest.json")
1491
1491
  with open(manifest_path + ".temp", "w") as f:
1492
1492
  json.dump(manifest, f, indent=2)
1493
- os.rename(manifest_path + ".temp", manifest_path) # Atomic write
1493
+ os.replace(manifest_path + ".temp", manifest_path) # Atomic write
1494
1494
  logger.debug(
1495
1495
  "Wrote manifest for {0} #{1}: {2} attachments".format(
1496
1496
  item_type_display, number, len(attachment_metadata_list)
@@ -1811,7 +1811,7 @@ def backup_issues(args, repo_cwd, repository, repos_template):
1811
1811
 
1812
1812
  with codecs.open(issue_file + ".temp", "w", encoding="utf-8") as f:
1813
1813
  json_dump(issue, f)
1814
- os.rename(issue_file + ".temp", issue_file) # Unlike json_dump, this is atomic
1814
+ os.replace(issue_file + ".temp", issue_file) # Atomic write
1815
1815
 
1816
1816
 
1817
1817
  def backup_pulls(args, repo_cwd, repository, repos_template):
@@ -1886,7 +1886,7 @@ def backup_pulls(args, repo_cwd, repository, repos_template):
1886
1886
 
1887
1887
  with codecs.open(pull_file + ".temp", "w", encoding="utf-8") as f:
1888
1888
  json_dump(pull, f)
1889
- os.rename(pull_file + ".temp", pull_file) # Unlike json_dump, this is atomic
1889
+ os.replace(pull_file + ".temp", pull_file) # Atomic write
1890
1890
 
1891
1891
 
1892
1892
  def backup_milestones(args, repo_cwd, repository, repos_template):
@@ -2090,11 +2090,13 @@ def fetch_repository(
2090
2090
  git_command.pop()
2091
2091
  logging_subprocess(git_command, cwd=local_dir)
2092
2092
  else:
2093
- if lfs_clone:
2094
- git_command = ["git", "lfs", "clone", remote_url, local_dir]
2095
- else:
2096
- git_command = ["git", "clone", remote_url, local_dir]
2093
+ git_command = ["git", "clone", remote_url, local_dir]
2097
2094
  logging_subprocess(git_command)
2095
+ if lfs_clone:
2096
+ git_command = ["git", "lfs", "fetch", "--all", "--prune"]
2097
+ if no_prune:
2098
+ git_command.pop()
2099
+ logging_subprocess(git_command, cwd=local_dir)
2098
2100
 
2099
2101
 
2100
2102
  def backup_account(args, output_directory):
@@ -2203,5 +2205,5 @@ def json_dump_if_changed(data, output_file_path):
2203
2205
  temp_file = output_file_path + ".temp"
2204
2206
  with codecs.open(temp_file, "w", encoding="utf-8") as f:
2205
2207
  f.write(new_content)
2206
- os.rename(temp_file, output_file_path) # Atomic on POSIX systems
2208
+ os.replace(temp_file, output_file_path) # Atomic write
2207
2209
  return True
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: github-backup
3
- Version: 0.55.0
3
+ Version: 0.56.0
4
4
  Summary: backup a github user or organization
5
5
  Home-page: http://github.com/josegonzalez/python-github-backup
6
6
  Author: Jose Diaz-Gonzalez
@@ -245,6 +245,8 @@ When you use the ``--lfs`` option, you will need to make sure you have Git LFS i
245
245
 
246
246
  Instructions on how to do this can be found on https://git-lfs.github.com.
247
247
 
248
+ LFS objects are fetched for all refs, not just the current checkout, ensuring a complete backup of all LFS content across all branches and history.
249
+
248
250
 
249
251
  About Attachments
250
252
  -----------------
@@ -390,6 +392,25 @@ Debug an error/block or incomplete backup into a temporary directory. Omit "incr
390
392
  github-backup -f $FINE_ACCESS_TOKEN -o /tmp/github-backup/ -l debug -P --all-starred --starred --watched --followers --following --issues --issue-comments --issue-events --pulls --pull-comments --pull-commits --labels --milestones --repositories --wikis --releases --assets --pull-details --gists --starred-gists $GH_USER
391
393
 
392
394
 
395
+ Restoring from Backup
396
+ =====================
397
+
398
+ This tool creates backups only, there is no inbuilt restore command.
399
+
400
+ **Git repositories, wikis, and gists** can be restored by pushing them back to GitHub as you would any git repository. For example, to restore a bare repository backup::
401
+
402
+ cd /tmp/white-house/repositories/petitions/repository
403
+ git push --mirror git@github.com:WhiteHouse/petitions.git
404
+
405
+ **Issues, pull requests, comments, and other metadata** are saved as JSON files for archival purposes. The GitHub API does not support recreating this data faithfully, creating issues via the API has limitations:
406
+
407
+ - New issue/PR numbers are assigned (original numbers cannot be set)
408
+ - Timestamps reflect creation time (original dates cannot be set)
409
+ - The API caller becomes the author (original authors cannot be set)
410
+ - Cross-references between issues and PRs will break
411
+
412
+ These are GitHub API limitations that affect all backup and migration tools, not just this one. Recreating issues with these limitations via the GitHub API is an exercise for the reader. The JSON backups remain useful for searching, auditing, or manual reference.
413
+
393
414
 
394
415
  Development
395
416
  ===========
@@ -0,0 +1,11 @@
1
+ github_backup/__init__.py,sha256=pLF99dIRilisWyZd9CliPPWqIlV81Xy8XtGEMuThTaM,23
2
+ github_backup/__main__.py,sha256=3yorCiC63maaxbjdtaeAs-G-yAAxKSO3mprhGfa1Fho,271
3
+ github_backup/cli.py,sha256=zMUU0pTnh9KPqv8K--KNpUNf-yaA1qWeI6AdC1KVrn8,2361
4
+ github_backup/github_backup.py,sha256=wlVrA50q5iP8BbJ_6WIIMEP7MKl_B3cKm2zvEtNYMS4,80777
5
+ github_backup-0.56.0.dist-info/licenses/LICENSE.txt,sha256=ML-pLyn1qtAKo_DHMcQ8-p7k3f8cp-IR-mf5B49R2rk,1085
6
+ github_backup-0.56.0.dist-info/METADATA,sha256=0N-CqtE9r3amkSHGkrgR3YeG7wylthaM0Q2RDct5vbc,24230
7
+ github_backup-0.56.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
8
+ github_backup-0.56.0.dist-info/entry_points.txt,sha256=cLPKK7MqC77QVb6HnT2mnyL_f-ciavJG_Y9vVHlCF68,57
9
+ github_backup-0.56.0.dist-info/top_level.txt,sha256=Za6fKRAlxZ0b3ZBH_osPqklLe14LetdNAkvAQANT2AA,14
10
+ github_backup-0.56.0.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
11
+ github_backup-0.56.0.dist-info/RECORD,,
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ github-backup = github_backup.cli:main
@@ -1,9 +0,0 @@
1
- github_backup/__init__.py,sha256=UQLHFqXC6UhDcoKB4MFAazCsPAeQEfBN68BEvb4D2Tk,23
2
- github_backup/github_backup.py,sha256=UMxNz_SWr7FGLYybd0RLtZu17vOwmUvZTMOlM3Uj6lk,80729
3
- github_backup-0.55.0.data/scripts/github-backup,sha256=E-kXsqfjwG3h6z9wRgWOdmrCwdUBMNhJwH63sCiAPQw,2250
4
- github_backup-0.55.0.dist-info/licenses/LICENSE.txt,sha256=ML-pLyn1qtAKo_DHMcQ8-p7k3f8cp-IR-mf5B49R2rk,1085
5
- github_backup-0.55.0.dist-info/METADATA,sha256=xJ5GAGwpxzZhi7hBnMm4jRNtZLRKvU0lj4ClDZrd6RA,22937
6
- github_backup-0.55.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
- github_backup-0.55.0.dist-info/top_level.txt,sha256=Za6fKRAlxZ0b3ZBH_osPqklLe14LetdNAkvAQANT2AA,14
8
- github_backup-0.55.0.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
9
- github_backup-0.55.0.dist-info/RECORD,,