Skip to content

Commit e5385ed

Browse files
committed
Initial commit
0 parents  commit e5385ed

7 files changed

Lines changed: 972 additions & 0 deletions

File tree

.github/workflows/test.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Test GitBackup
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
name: Test on Ubuntu
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v3
17+
18+
- name: Make script executable
19+
run: chmod +x gitbackup
20+
21+
- name: Test help command
22+
run: ./gitbackup --help
23+
24+
- name: Test version command
25+
run: ./gitbackup --version
26+
27+
- name: Create test git repository
28+
run: |
29+
mkdir -p /tmp/test-repos/project1
30+
cd /tmp/test-repos/project1
31+
git config --global user.email "test@test.com"
32+
git config --global user.name "Test User"
33+
git init
34+
echo "test content" > file.txt
35+
git add .
36+
git commit -m "Initial commit"
37+
38+
- name: Test scan command
39+
run: |
40+
./gitbackup scan /tmp/test-repos
41+
echo "✓ Scan completed"
42+
43+
- name: Test list command
44+
run: |
45+
./gitbackup list
46+
echo "✓ List completed"
47+
48+
- name: Test backup command
49+
run: |
50+
mkdir -p /tmp/backup-test
51+
./gitbackup backup -d /tmp/backup-test
52+
echo "✓ Backup completed"
53+
54+
- name: Test compressed backup
55+
run: |
56+
mkdir -p /tmp/backup-compressed
57+
./gitbackup backup -d /tmp/backup-compressed --compress
58+
echo "✓ Compressed backup completed"
59+
60+
- name: Verify backup was created
61+
run: |
62+
ls -la /tmp/backup-compressed/
63+
echo "✓ Backup files verified"
64+
65+
- name: Test status command
66+
run: |
67+
./gitbackup status
68+
echo "✓ Status check completed"
69+
70+
- name: Test log command
71+
run: |
72+
./gitbackup log || true
73+
echo "✓ Log command completed"
74+
75+
- name: Install shellcheck
76+
run: |
77+
sudo apt-get update
78+
sudo apt-get install -y shellcheck
79+
80+
- name: Run shellcheck
81+
continue-on-error: true
82+
run: shellcheck gitbackup
83+
84+
- name: Verify script structure
85+
run: |
86+
grep -q "scan_repos()" gitbackup
87+
grep -q "list_repos()" gitbackup
88+
grep -q "backup_repo()" gitbackup
89+
echo "✓ Script structure verified"
90+
91+
- name: All tests passed
92+
run: |
93+
echo "================================"
94+
echo "✓ All tests passed successfully!"
95+
echo "================================"

.gitignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Test files
2+
test/
3+
tests/
4+
*.test
5+
test-repos/
6+
7+
# Test backups
8+
backup-test/
9+
*.tar.gz
10+
11+
# Editor files
12+
*.swp
13+
*.swo
14+
*~
15+
.vscode/
16+
.idea/
17+
18+
# OS files
19+
.DS_Store
20+
Thumbs.db

CONTRIBUTING.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Contributing to GitBackup
2+
3+
Thanks for your interest! 🎉
4+
5+
## Reporting Bugs
6+
7+
- Check existing issues first
8+
- Include your OS and bash version
9+
- Provide the command you ran
10+
- Include error messages
11+
- Describe expected vs actual behavior
12+
13+
## Suggesting Features
14+
15+
- Check if already suggested
16+
- Explain the use case
17+
- Describe how it would work
18+
- Consider if it fits the project scope
19+
20+
## Pull Requests
21+
22+
1. Fork the repository
23+
2. Create feature branch
24+
3. Test thoroughly with real repos
25+
4. Follow existing code style
26+
5. Update README if needed
27+
6. Submit PR with clear description
28+
29+
## Testing
30+
31+
```bash
32+
# Test with sample repos
33+
mkdir -p /tmp/test-repos/project1
34+
cd /tmp/test-repos/project1
35+
git init
36+
echo "test" > file.txt
37+
git add .
38+
git commit -m "Initial commit"
39+
40+
# Test gitbackup
41+
chmod +x gitbackup
42+
./gitbackup scan /tmp/test-repos
43+
./gitbackup list
44+
./gitbackup backup -d /tmp/backup-test
45+
```
46+
47+
## Code Style
48+
49+
- 4 spaces indentation
50+
- Clear variable names
51+
- Comment complex logic
52+
- Follow existing patterns
53+
54+
## License
55+
56+
By contributing, you agree your contributions will be licensed under MIT.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Sean Baggett
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
# GitBackup - Automated Git Repository Backup Manager
2+
3+
Never lose your code again! GitBackup automatically discovers and backs up all your git repositories with one command.
4+
5+
## Why GitBackup?
6+
7+
Every developer's nightmare: **"My hard drive died and I lost 3 months of work."**
8+
9+
- 🔍 **Auto-discovers** all git repos
10+
- 💾 **One-command backups** to external drives
11+
-**Incremental** - only backup what changed
12+
- ⚠️ **Detects uncommitted changes**
13+
- 📦 **Compression** - save space
14+
- 📊 **Status tracking**
15+
- 📝 **Backup logs**
16+
17+
## Installation
18+
19+
```bash
20+
curl -sSL https://raw.githubusercontent.com/strabo231/gitbackup/main/install.sh | bash
21+
```
22+
23+
## Quick Start
24+
25+
```bash
26+
# Scan your projects
27+
gitbackup scan ~/Projects ~/Work
28+
29+
# See what was found
30+
gitbackup list
31+
32+
# Backup to external drive
33+
gitbackup backup -d /media/backup --compress
34+
35+
# Check status
36+
gitbackup status
37+
```
38+
39+
## Commands
40+
41+
**Scan for repos:**
42+
```bash
43+
gitbackup scan ~/Projects
44+
```
45+
46+
**List tracked repos:**
47+
```bash
48+
gitbackup list
49+
```
50+
51+
**Backup all repos:**
52+
```bash
53+
gitbackup backup -d /media/backup --compress
54+
gitbackup backup -d /media/backup --incremental # Only changed repos
55+
```
56+
57+
**Check status:**
58+
```bash
59+
gitbackup status # Shows uncommitted changes, etc.
60+
```
61+
62+
**Restore:**
63+
```bash
64+
gitbackup restore /media/backup/myproject.tar.gz ~/restored
65+
```
66+
67+
**View history:**
68+
```bash
69+
gitbackup log
70+
```
71+
72+
## Use Cases
73+
74+
**Daily backup:**
75+
```bash
76+
gitbackup backup -d /media/usb --incremental
77+
```
78+
79+
**Weekly full backup:**
80+
```bash
81+
gitbackup backup -d /mnt/nas/backups --compress
82+
```
83+
84+
**Setup cron:**
85+
```bash
86+
# Daily at 6 PM
87+
crontab -e
88+
0 18 * * * gitbackup backup -d /media/backup --incremental
89+
```
90+
91+
## Features
92+
93+
✅ Auto-discovers git repos recursively
94+
✅ Detects uncommitted work
95+
✅ Incremental backups (only changed repos)
96+
✅ Compressed archives (.tar.gz)
97+
✅ Smart filtering (skips node_modules, venv, etc.)
98+
✅ Backup logs with timestamps
99+
✅ Restore from backups
100+
✅ Status overview
101+
102+
## Command Reference
103+
104+
```
105+
scan <dir> Find git repos
106+
list List tracked repos
107+
backup -d <dest> Backup all repos
108+
--compress Create .tar.gz
109+
--incremental Only changed repos
110+
--exclude <pattern> Skip matching repos
111+
status Show repo states
112+
restore <file> [dest] Restore backup
113+
log Show history
114+
```
115+
116+
## License
117+
118+
MIT License - see [LICENSE](LICENSE)
119+
120+
## Author
121+
122+
Sean - [@strabo231](https://github.com/strabo231)
123+
124+
---
125+
126+
**Don't risk losing your work. Backup your repos today.** 💾

0 commit comments

Comments
 (0)