If you love coding locally but always mean to back things up (and never do), this tool’s for you. It automatically syncs your Python scripts to Google Drive and keeps detailed changelogs—so your work stays safe, your history’s tracked, and you can focus on building, not backing up.
- Python 3.7 or higher installed
- pip (Python package installer)
Install required packages using:
pip install -r requirements.txt- Visit Google Cloud Console
- Create a new project (or select existing)
- Enable Google Drive API:
- Go to "APIs & Services" → "Library"
- Search for "Google Drive API"
- Click "Enable"
- Set up OAuth consent screen:
- Go to "APIs & Services" → "OAuth consent screen"
- Choose "External"
- Fill in app name (e.g., "DriveSync")
- Add your email as developer contact
- Save and continue
- Create OAuth credentials:
- Go to "Credentials"
- Click "Create Credentials" → "OAuth client ID"
- Choose "Desktop application"
- Download JSON file
- Rename to
client_secrets.jsonand place in project directory
- Clone or download the code and place all the files in your project directory
- Install requirements:
pip install -r requirements.txt- Place
client_secrets.jsonin project directory as well - Run the sync:
python sync.py --folder-name "MyBackups"- Monitors Python files (or specified file types)
- Syncs changes every 2 minutes (configurable)
- Only uploads when files actually change
- Maintains detailed changelogs
- Records what changed and when
- Stores diffs for each change
# Custom folder name and sync interval
python sync.py --folder-name "ProjectBackup" --interval 60
# Sync multiple file types
python sync.py --file-types ".py,.txt,.md"
# Enable debug logging
python sync.py --debug# View changelog for specific file
python sync.py --view-changes script.py-
Authentication
- First run opens browser for Google login
- Stores token for future use
- No need to re-authenticate unless token expires
-
File Monitoring
- Scans directory for specified file types
- Calculates MD5 hash of each file
- Detects changes by comparing hashes
-
Change Management
- Creates changelog entry for each change
- Stores unified diffs showing exactly what changed
- Organizes changes by file and timestamp
-
Drive Sync
- Creates dedicated folder in your Drive
- Uploads changed files automatically
- Maintains file hierarchy
project/
├── changelogs/ # Change history
│ ├── script1.py_logs/
│ │ ├── index.json
│ │ └── changes_*.diff
│ └── script2.py_logs/
├── client_secrets.json # Google OAuth credentials
├── token.pickle # Stored auth token
├── drive_sync.py # Main sync code
└── sync.py # Command line interface
-
First Time Setup
- Run with
--debugflag to see detailed logs - Check Google Drive to verify folder creation
- Try modifying a file to test sync
- Run with
-
Efficient Usage
- Let it run in a terminal while you work
- Check changelogs to track your changes
- Use custom intervals based on your needs
-
Troubleshooting
- Delete
token.pickleif auth issues occur - Enable debug logging for detailed info
- Check changelog directory for sync history
- Delete
- Backups? Done. Even if you forgot, this tool didn’t. 🎈
- The changelog knows more about your code history than your memory ever will! 🧠
- Runs quietly in the background, like a cron job with commitment issues (but it always shows up) 😴
Remember: With great automation comes great responsibility... and fewer excuses for not backing up your code! 😉
Check the logs, they're your friends! If you see something like "File synced successfully", celebrate! If not, the debug logs will tell you why - they're chatty like that! 🗣️
Happy coding and syncing! 🚀