A tool to automatically clone and backup GitHub repositories to SMB network shares. This project fetches repositories from specified GitHub users or organizations and stores them both locally and on remote SMB shares for archival purposes.
- 🔄 Fetch repositories from GitHub users or organizations
- 📦 Clone repositories locally for processing
- 🌐 Upload to SMB network shares for remote storage
- ⚡ Concurrent processing with configurable limits
- 🎨 Colored console output for better visibility
- 🔧 Configurable via TypeScript configuration file
- Bun runtime
- Git installed on your system
- Access to SMB network share (if using remote backup)
- GitHub token for API access (recommended for higher rate limits)
-
Clone this repository: git clone cd github-archive
-
Install dependencies: bun install
-
Configure your settings in config.ts:
export const config = {
githubUser: 'your-github-username',
githubToken: 'your-github-token', // Optional but recommended
orgName: 'your-organization-name', // Optional
smbUser: 'smb-username',
smbPass: 'smb-password',
smbServer: '192.168.1.100',
smbShare: 'backup',
smbRemotePath: 'github-repos/2025',
tmpDir: '/tmp/github_repos',
concurrency: 5, // Number of concurrent operations
};
The config.ts file contains all necessary configuration options:
| Option | Description | Required |
|---|---|---|
| githubUser | GitHub username to fetch repositories from | Yes |
| githubToken | GitHub personal access token | Recommended |
| orgName | GitHub organization name (alternative to user) | Optional |
| smbUser | SMB share username | Yes (if using SMB) |
| smbPass | SMB share password | Yes (if using SMB) |
| smbServer | SMB server IP address | Yes (if using SMB) |
| smbShare | SMB share name | Yes (if using SMB) |
| smbRemotePath | Remote path within SMB share | Yes (if using SMB) |
| tmpDir | Temporary directory for cloning | Yes |
| concurrency | Number of concurrent operations | Yes |
Run the archive process: bun run index.ts
The tool will:
- Fetch all repositories from the specified GitHub user/organization
- Clone each repository to the temporary directory
- Upload the repositories to the configured SMB share
- Clean up temporary files
- index.ts - Main application entry point
- config.ts - Configuration file
- package.json - Project dependencies and scripts
- README.md - This documentation file
- colors - For colored console output
- @types/bun - TypeScript types for Bun runtime
The application includes comprehensive error handling for:
- GitHub API failures
- Git clone operations
- SMB connection and upload issues
- File system operations
All errors are logged with colored output for easy identification.
- Store your GitHub token securely and never commit it to version control
- Use environment variables or secure configuration management for sensitive data
- Ensure SMB credentials are properly secured
- The temporary directory is cleaned up after each run
This project is provided as-is for archival purposes.
Feel free to submit issues