Professional solution for automatic cloning and backup of GitHub repositories and gists with enhanced reliability
- Complete Backup - Clone both public and private repositories/gists
- Smart Update System - Existing clones are updated via
git pull
- Resilient Retry Mechanism - 5 automatic retries for failed operations
- Archive Support - Create compressed ZIP archives
- System Control - Option to shutdown/reboot after completion
- Real-time Monitoring - Improved progress bar with statistics
- Cross-platform - Works on Linux and Termux (Android)
- Added new --reboot flag that performs system reboot after completion
- Made --reboot and --shutdown mutually exclusive using argparse group
- Added reboot() method similar to shutdown() but for system restart
- Changed the priority of receiving and checking information when initializing the application
- Fixed incorrect display of some user interface elements
git clone https://github.com/smartlegionlab/github_repos_backup_tools.git
cd github_repos_backup_tools
Create .config.ini
file:
[github]
token = your_github_token_here
- Visit GitHub Tokens
- Select permissions:
- β
repo
(full repository access) - β
gist
(gist access)
- β
- Generate and copy token
# Generate SSH key
ssh-keygen -t ed25519 -C "your_email@example.com"
# Add to ssh-agent
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
# Add to GitHub account
cat ~/.ssh/id_ed25519.pub # Copy this output
# Paste at https://github.com/settings/keys
# Verify connection
ssh -T git@github.com
Command | Description |
---|---|
-r |
Clone all repositories |
-g |
Clone all gists |
--archive |
Create compressed backup archive |
--verbose |
Show detailed debug output |
--shutdown |
Shutdown computer after completion |
--reboot |
Restart computer after completion |
Common Command Combinations:
# Basic backup
python app.py -r -g
# Backup with archive creation
python app.py -r --archive
# Full backup with shutdown
python app.py -r -g --shutdown
# Debug mode
python app.py -g --verbose
Backups are organized in your home directory:
~/
βββ [username]_github_backup/
βββ repositories/ # All cloned repositories
βββ gists/ # All cloned gists
[username]_github_backup.zip # Created when using --archive
- Retry Logic: 5 attempts for each clone/update operation
- Timeout: 20 seconds per git operation
- Error Handling: Automatic cleanup of failed clones
- Progress Tracking: Real-time visual feedback
- System Integration: Supports shutdown/reboot commands
Q: How to cancel scheduled shutdown?
A: Use shutdown -c
(Linux) or shutdown /a
(Windows)
Q: Where are backups stored?
A: In ~/[your_username]_github_backup/
Q: How to update existing clones?
A: Just run the tool again - it automatically does git pull
v0.9.1 Updates:
- Added new --reboot flag that performs system reboot after completion
- Made --reboot and --shutdown mutually exclusive using argparse group
- Added reboot() method similar to shutdown() but for system restart
- Changed the priority of receiving and checking information when initializing the application
- Fixed incorrect display of some user interface elements
Author: A.A. Suvorov
License: BSD 3-Clause "New" or "Revised" License
Support: Open issue on GitHub
Example output without using the --verbose
flag:
python app.py -r -g
************************************************************************************************************************
------------------------------------------- Github Repositories Backup Tools -------------------------------------------
------------------------------------------------------------------------------------------------------------------------
Getting a token from a .config.ini file: β
Checking the token for validity:
Token is valid: β
Getting user login:
β
Login: login
Parsing arguments:
Clone repositories: β
Clone gists: β
Make archive: β
Shutdown: β
Reboot: β
Verbose: β
Forming a path to the directory:
β
Path: /home/user/#_github_backup
------------------------------------------------------------------------------------------------------------------------
------------------------------------------------ Cloning repositories: ------------------------------------------------
------------------------------------------------------------------------------------------------------------------------
Target directory: /home/user/#_github_backup/repositories
------------------------------------------------------------------------------------------------------------------------
Getting repositories:
-------------------------
β
Found 248 repositories.
-------------------------
[################################################--] 97.98% | 243/248 | Failed: 9 | Cloning: repo243
Example output when using the --verbose
flag:
python app -r -g --verbose
************************************************************************************************************************
------------------------------------------- Github Repositories Backup Tools -------------------------------------------
------------------------------------------------------------------------------------------------------------------------
Getting a token from a .config.ini file: β
Checking the token for validity:
Token is valid: β
Getting user login:
β
Login: login
Parsing arguments:
Clone repositories: β
Clone gists: β
Make archive: β
Shutdown: β
Reboot: β
Verbose: β
Forming a path to the directory:
β
Path: /home/user/#_github_backup
------------------------------------------------------------------------------------------------------------------------
------------------------------------------------ Cloning repositories: ------------------------------------------------
------------------------------------------------------------------------------------------------------------------------
Target directory: /home/user/#_github_backup/repositories
------------------------------------------------------------------------------------------------------------------------
Getting repositories:
-------------------------
β
Found 3 repositories.
-------------------------
---------------------------------------
1/3/0: Cloning: login/repo1
---------------------------------------
β
Repository updated successfully:
/home/user/#_github_backup/repositories/#/repo1
------------------------------------------------
2/3/0: Cloning: login/repo2
------------------------------------------------
β Pull operation timed out:
/home/user/#_github_backup/repositories/#/repo2
β Pull failed. Removing and re-cloning:
/home/user/#_github_backup/repositories/#/repo2
β Clone operation timed out:
/home/user/#_github_backup/repositories/#/repo2
β Removing incomplete repositories:
/home/user/#_github_backup/repositories/#/repo2
---------------------------------------------------------------
3/3/1: Cloning: login/repo3
---------------------------------------------------------------
β Pull operation timed out:
/home/user/#_github_backup/repositories/#/repo3
β Pull failed. Removing and re-cloning:
/home/user/#_github_backup/repositories/#/repo3
β
Repository cloned successfully:
/home/user/#_github_backup/repositories/#/repo3
------------------------------------------------------------------------------------------------------------------------
-----------------------------------------
Retrying failed repositories: 1 remaining
-----------------------------------------
------------------------------------------------------------
1/1/1: Retrying: login/repo2
------------------------------------------------------------
β
Repository cloned successfully:
/home/user/#_github_backup/repositories/#/repo2
------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------- Cloning gists: ----------------------------------------------------
------------------------------------------------------------------------------------------------------------------------
Target directory: /home/user/#_github_backup/gists
------------------------------------------------------------------------------------------------------------------------
Getting gists:
------------------
β
Found 3 gists.
------------------
--------------------------------------------------
1/3/0: Cloning: name1
--------------------------------------------------
β
Repository updated successfully:
/home/user/#_github_backup/gists/name1
--------------------------------------------------
2/3/0: Cloning: name2
--------------------------------------------------
β Pull operation timed out:
/home/user/#_github_backup/gists/name2
β Pull failed. Removing and re-cloning:
/home/user/#_github_backup/gists/name2
β Clone operation timed out:
/home/user/#_github_backup/gists/name2
β Removing incomplete gists:
/home/user/#_github_backup/gists/name2
--------------------------------------------------
3/3/1: Cloning: name3
--------------------------------------------------
β Pull operation timed out:
/home/user/#_github_backup/gists/name3
β Pull failed. Removing and re-cloning:
/home/user/#_github_backup/gists/name3
β
Repository cloned successfully:
/home/user/#_github_backup/gists/name3
------------------------------------------------------------------------------------------------------------------------
----------------------------------
Retrying failed gists: 1 remaining
----------------------------------
------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------
1/1/1: Retrying: name2
-------------------------------------------------
β
Repository cloned successfully:
/home/user/#_github_backup/gists/name2
------------------------------------------------------------------------------------------------------------------------
------------------------------------------ https://github.com/smartlegionlab/ ------------------------------------------
------------------------------------------ Copyright Β© 2018-2025, A.A. Suvorov -----------------------------------------
************************************************************************************************************************
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------
Licensed under the terms of the BSD 3-Clause License
(see LICENSE for details).
Copyright Β© 2018-2025, A.A. Suvorov
All rights reserved.
--------------------------------------------------------