arefshojaei/github-backup

Github backup manager

Maintainers

Package info

github.com/ArefShojaei/Github-backup

Type:project

pkg:composer/arefshojaei/github-backup

Transparency log

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

dev-main 2026-08-22 14:00 UTC

This package is auto-updated.

Last update: 2026-08-22 14:00:45 UTC


README

PHP Version License GitHub

A lightweight and simple GitHub backup manager CLI built with PHP.

GitHub Backup Manager allows you to interact with your GitHub profile directly from the command line, inspect your repositories, view profile information, and create local backups of your public repositories.

✨ Features

  • 🐙 GitHub API Integration - Connect to GitHub using your personal access token
  • 💾 Repository Backup - Backup your public GitHub repositories locally
  • 📦 Repository Manager - List and inspect your GitHub repositories from the CLI
  • 👤 Profile Information - Display GitHub profile information in a clean terminal interface
  • 🖥️ CLI Based - Everything works directly from your terminal
  • Lightweight - Simple architecture with minimal overhead
  • 🔐 Environment Configuration - Keep your GitHub token inside a .env file
  • 🧩 Extensible Architecture - Built with separated commands, services, utilities, and contracts
  • 🐘 Modern PHP - Designed for PHP 8.0+

🏗️ Project Structure

The project follows a simple and organized structure:

Github-backup/
│
├── bin/
│   └── cli
│
├── src/
│   ├── Console/
│   │   └── Commands/
│   │       ├── BackupCommand.php
│   │       ├── ProfileCommand.php
│   │       └── RepoCommand.php
│   │
│   ├── Contracts/
│   ├── Services/
│   ├── Utils/
│   └── helpers/
│
├── .env.example
├── .gitignore
├── composer.json
├── package.json
└── README.md

The CLI commands are separated from the GitHub service and backup logic, making the project easier to maintain and extend.

📥 Installation & Setup

Requirements

Before installing the project, make sure you have:

  • PHP 8.0 or higher
  • Composer
  • Git
  • A GitHub Personal Access Token

Install with Composer

composer create-project arefshojaei/github-backup:dev-main my-github-backup
cd my-github-backup

Clone the Repository

git clone https://github.com/ArefShojaei/Github-backup.git
cd Github-backup

Install Dependencies

Install the PHP dependencies using Composer:

composer install

🔐 Configuration

Create your environment file:

cp .env.example .env

Then add your GitHub token:

GITHUB_TOKEN=your_github_token

The application uses the GITHUB_TOKEN environment variable to authenticate with the GitHub API.

Security: Never commit your .env file or expose your GitHub token publicly.

🚀 Usage

The application provides several CLI commands for interacting with your GitHub account.

Run the CLI using:

php bin/cli

👤 View GitHub Profile

Display information about your GitHub profile:

php bin/cli profile

The command displays information such as:

  • Profile URL
  • Avatar URL
  • Public repository count
  • Followers
  • Following
  • Account creation date
  • Last update date

📦 List Repositories

Display your public GitHub repositories:

php bin/cli repo

The repository command shows useful information including:

  • Repository ID
  • Repository name
  • Repository URL
  • Description
  • Creation date
  • Last update date

Private repositories are currently skipped by the repository listing command.

💾 Backup Repositories

Create a local backup of your public GitHub repositories:

php bin/cli backup

The backup command:

  1. Connects to GitHub using your configured token
  2. Retrieves your repositories
  3. Skips private repositories
  4. Creates a local backup/ directory
  5. Creates a backup for each public repository

The generated backups are stored inside:

backup/
├── repository-one/
├── repository-two/
├── repository-three/
└── ...

🧠 How It Works

The project uses the GitHub API to retrieve repository and profile information.

The general workflow looks like this:

GitHub
   │
   ▼
GitHub API
   │
   ▼
GithubService
   │
   ├── Profile Command
   │
   ├── Repository Command
   │
   └── Backup Command
            │
            ▼
       Local Backup

The GithubService handles communication with GitHub, while individual CLI commands are responsible for presenting information or performing backup operations.

🛠️ Development

Install the project dependencies:

composer install

The project also includes Prettier configuration for formatting PHP files.

Format the project:

npm install
npm run format

Check formatting without modifying files:

npm run format:check

🔧 Available Commands

Command Description
profile Display GitHub profile information
repo List public repositories
backup Create local backups of public repositories

🔒 Security

Your GitHub Personal Access Token is sensitive information.

Make sure you:

  • Keep your token inside .env
  • Never commit .env to Git
  • Never share your token publicly
  • Use a token with only the permissions required for your use case
  • Rotate your token if it is accidentally exposed

🤝 Contributing

Contributions are always welcome!

If you have an idea, bug fix, improvement, or new feature, feel free to contribute.

1. Fork the repository

git clone https://github.com/ArefShojaei/Github-backup.git
cd Github-backup

2. Create a feature branch

git checkout -b feature/amazing-feature

3. Commit your changes

git commit -m "Add amazing feature"

4. Push your branch

git push origin feature/amazing-feature

5. Open a Pull Request

Once your changes are pushed, open a Pull Request on GitHub.

👨‍💻 Author

Aref Shojaei

⭐ Show Your Support

If this project is useful to you, consider giving it a Star ⭐ on GitHub.

Your support helps the project grow and motivates further development.