A Python-based application that automatically synchronizes local folders to cloud storage providers on a scheduled basis.
- Automatic Synchronization: Schedule periodic uploads of local folders to cloud storage
- Multiple Folders: Configure multiple folders with different sync intervals and settings
- File Compression: Optionally compress files before uploading to save storage space
- Exclude Patterns: Define patterns to exclude specific files or folders from sync
- Desktop Notifications: Get notified when reconnection to cloud provider is needed
- Logging: Comprehensive logging system to track all sync operations
| Provider | Status | Documentation |
|---|---|---|
| Google Drive | β Available | Setup Guide |
| OneDrive | π Coming Soon | - |
| Dropbox | π Coming Soon | - |
- Prerequisites
- Python 3.8 or higher
- Get the code:
Option A: Clone the repository
git clone <repository-url>
cd sync-files-to-cloudOption B: Download from releases
- Go to the Releases page
- Download the latest release (Source code.zip or Source code.tar.gz)
- Extract the archive and navigate to the folder
- Create and activate a virtual environment:
# Create virtual environment
python -m venv venv- Activate virtual environment
venv\Scripts\activatesource venv/bin/activate- Install required dependencies:
pip install -r requirements.txt- Set up cloud provider credentials:
- For Google Drive: Follow the Google Drive Setup Guide
- Place your
gdrive_credentials.jsonfile in thecredentials/folder
Edit the config.yaml file to configure your synchronization settings:
logging:
level: "INFO"
file_path: "app.log"
sync:
- name: my_images
cloud_provider: "GoogleDrive"
sync_interval: 60 # in minutes
compress: true
local_path: "C:/Users/Username/Documents/Images" # Absolute path to local folder. Can be a string or a list of strings
remote_path: "/images"
exclude_patterns: # work like a .gitignore file
- "*.tmp"
- "temp_folder/*"Other exemple with multiple local paths and exclude patterns:
local_path:
- "/home/user/.config"
- "/home/user/.oh-my-zsh"
exclude_patterns:
- "*"
- "!neofetch"
- "!kitty"
- "!custom/themes"
- "!nvim"- name: Unique identifier for the sync folder
- cloud_provider: Cloud storage provider (currently only "GoogleDrive")
- sync_interval: Time between syncs in seconds
- compress: Whether to compress files into a zip archive before upload
- local_path: Absolute path to the local folder to sync
- remote_path: Destination path in the cloud storage
- exclude_patterns: List of patterns to exclude files (supports wildcards like
*.tmp,folder/*)
See the 'usage' section for commands to restart the application depending on your OS.
Run the application:
python main.pyThe application will:
- Initialize connections to configured cloud providers
- Perform an initial sync for all configured folders
- Schedule periodic syncs based on the configured intervals
- Continue running until stopped (Ctrl+C)
To automatically run the script when your computer starts:
Windows Instructions
- Setup the powershell script
Go in the /scripts folder, open activate-scheduled-task.ps1and edit the line 3:
$projectPath = "path to the project" # Put the absolute path to this project- Run the script as administrator
open a powershell terminal as administator and run
path/to/activate-scheduled-task.ps1you can run the deactivation script scripts\remove-scheduled-task.ps1
you can run the restart script scripts\restart-scheduled-task.ps1
Start-ScheduledTask -TaskName "Sync-files-task"Stop-ScheduledTask -TaskName "Sync-files-task"Linux Instructions (systemd)
- Create a systemd service file
/etc/systemd/system/sync-files.service:
don't forget to replace the paths and username
[Unit]
Description = Sync Files to Cloud
After = network.target
[Service]
; replace the paths below with the project path
ExecStart = /path/to/sync-files-to-cloud/venv/bin/python /path/to/sync-files-to-cloud/main.py
WorkingDirectory = /path/to/sync-files-to-cloud
; Replace 'your-username' with the appropriate user
User = your-username
Restart = on-failure
[Install]
WantedBy = multi-user.target- Enable and start the service:
sudo systemctl enable sync-files.service
sudo systemctl start sync-files.serviceTo stop and disable the service:
sudo systemctl stop sync-files.service
sudo systemctl disable sync-files.serviceTo restart the service:
sudo systemctl restart sync-files.service- Configuration Loading: The application reads
config.yamlto load sync parameters - Cloud Authentication: Connects to cloud providers using credentials from the
credentials/folder - File Discovery: Scans local folders and filters files based on exclude patterns
- Compression (optional): Compresses files into a zip archive
- Upload: Uploads files to the cloud provider while preserving folder structure
- Scheduling: Repeats the process at configured intervals
- Error Handling: If connection fails, sends desktop notification to reconnect
- Check that the local path exists and is accessible
- Verify exclude patterns are not blocking desired files
- Review logs in
app.logfor detailed error messages
Contributions are welcome! Please feel free to submit pull requests or open issues.