Skip to content

Commit a194fa4

Browse files
committed
feat: Add attachment download support for issues and pull requests
Adds new --attachments flag that downloads user-uploaded files from issue and PR bodies and comments. Key features: - Determines attachment URLs - Tracks downloads in manifest.json with metadata - Supports --skip-existing to avoid re-downloading - Handles filename collisions with counter suffix - Smart retry logic for transient vs permanent failures - Uses Content-Disposition for correct file extensions
1 parent 8f859be commit a194fa4

File tree

2 files changed

+637
-3
lines changed

2 files changed

+637
-3
lines changed

README.rst

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ CLI Help output::
5050
[--keychain-name OSX_KEYCHAIN_ITEM_NAME]
5151
[--keychain-account OSX_KEYCHAIN_ITEM_ACCOUNT]
5252
[--releases] [--latest-releases NUMBER_OF_LATEST_RELEASES]
53-
[--skip-prerelease] [--assets]
53+
[--skip-prerelease] [--assets] [--attachments]
5454
[--exclude [REPOSITORY [REPOSITORY ...]]
5555
[--throttle-limit THROTTLE_LIMIT] [--throttle-pause THROTTLE_PAUSE]
5656
USER
@@ -133,6 +133,9 @@ CLI Help output::
133133
--skip-prerelease skip prerelease and draft versions; only applies if including releases
134134
--assets include assets alongside release information; only
135135
applies if including releases
136+
--attachments download user-attachments from issues and pull requests
137+
to issues/attachments/{issue_number}/ and
138+
pulls/attachments/{pull_number}/ directories
136139
--exclude [REPOSITORY [REPOSITORY ...]]
137140
names of repositories to exclude from backup.
138141
--throttle-limit THROTTLE_LIMIT
@@ -213,6 +216,29 @@ When you use the ``--lfs`` option, you will need to make sure you have Git LFS i
213216
Instructions on how to do this can be found on https://git-lfs.github.com.
214217

215218

219+
About Attachments
220+
-----------------
221+
222+
When you use the ``--attachments`` option with ``--issues`` or ``--pulls``, the tool will download user-uploaded attachments (images, videos, documents, etc.) from issue and pull request descriptions and comments. In some circumstances attachments contain valuable data related to the topic, and without their backup important information or context might be lost inadvertently.
223+
224+
Attachments are saved to ``issues/attachments/{issue_number}/`` and ``pulls/attachments/{pull_number}/`` directories, where ``{issue_number}`` is the GitHub issue number (e.g., issue #123 saves to ``issues/attachments/123/``). Each attachment directory contains:
225+
226+
- The downloaded attachment files (named by their GitHub identifier with appropriate file extensions)
227+
- If multiple attachments have the same filename, conflicts are resolved with numeric suffixes (e.g., ``report.pdf``, ``report_1.pdf``, ``report_2.pdf``)
228+
- A ``manifest.json`` file documenting all downloads, including URLs, file metadata, and download status
229+
230+
The tool automatically extracts file extensions from HTTP headers to ensure files can be more easily opened by your operating system.
231+
232+
**Supported URL formats:**
233+
234+
- Modern: ``github.com/user-attachments/{assets,files}/*``
235+
- Legacy: ``user-images.githubusercontent.com/*`` and ``private-user-images.githubusercontent.com/*``
236+
- Repo files: ``github.com/{owner}/{repo}/files/*`` (filtered to current repository)
237+
- Repo assets: ``github.com/{owner}/{repo}/assets/*`` (filtered to current repository)
238+
239+
**Repository filtering** for repo files/assets handles renamed and transferred repositories gracefully. URLs are included if they either match the current repository name directly, or redirect to it (e.g., ``willmcgugan/rich`` redirects to ``Textualize/rich`` after transfer).
240+
241+
216242
Run in Docker container
217243
-----------------------
218244

@@ -303,7 +329,7 @@ Quietly and incrementally backup useful Github user data (public and private rep
303329
export FINE_ACCESS_TOKEN=SOME-GITHUB-TOKEN
304330
GH_USER=YOUR-GITHUB-USER
305331

306-
github-backup -f $FINE_ACCESS_TOKEN --prefer-ssh -o ~/github-backup/ -l error -P -i --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
332+
github-backup -f $FINE_ACCESS_TOKEN --prefer-ssh -o ~/github-backup/ -l error -P -i --all-starred --starred --watched --followers --following --issues --issue-comments --issue-events --pulls --pull-comments --pull-commits --labels --milestones --repositories --wikis --releases --assets --attachments --pull-details --gists --starred-gists $GH_USER
307333
308334
Debug an error/block or incomplete backup into a temporary directory. Omit "incremental" to fill a previous incomplete backup. ::
309335

0 commit comments

Comments
 (0)