DEV Community

Mate Technologies
Mate Technologies

Posted on

πŸš€ FileSync PRO v4.0.0: Enterprise Backup & Sync Suite in Python

Tutorial for developers, IT pros, and power users
Direct download & release: FileSync PRO v4.0.0

SEO tags: Python backup tool, file synchronization Python, Tkinter file sync, Python multi-thread copy, real-time folder monitoring, encrypted backups Python, professional desktop tools

πŸ—οΈ Architecture Overview

FileSync PRO is built with Python using:

Tkinter + ttkbootstrap β†’ Modern GUI

Watchdog β†’ Real-time folder monitoring

ThreadPoolExecutor β†’ Multi-threaded copy engine

Cryptography (Fernet) β†’ Optional encrypted backups

Hash verification β†’ Ensures data integrity

Architecture Diagram
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Source Folder│──────>β”‚ Sync Engine β”‚
β”‚ β”‚ β”‚ β”‚
β”‚ Real-time β”‚ β”‚ Multi-thread β”‚
β”‚ Monitoring β”‚ β”‚ File Copy β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚ β”‚
β”‚ β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”
β”‚ β”‚ Target β”‚
β”‚ β”‚ Folder β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ β”‚ Backup β”‚
└─────────────────>β”‚ (ZIP & β”‚
β”‚ Encryptionβ”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
1️⃣ Setting Up the Project

Install required packages:

pip install ttkbootstrap watchdog cryptography

ttkbootstrap β†’ Modern Tkinter styling

watchdog β†’ File system events for real-time sync

cryptography β†’ Optional encryption of backups

Create your main Python file, e.g., filesync_pro.py.

2️⃣ Initializing the App

Start by importing necessary modules and setting up the basic app window:

import tkinter as tk
from queue import Queue
import ttkbootstrap as tb
from ttkbootstrap.constants import *

# App Configuration
APP_NAME = "FileSync PRO"
APP_VERSION = "4.0.0"

# UI queue for thread-safe logging
ui_queue = Queue()

# Initialize main window
app = tk.Tk()
app.title(f"{APP_NAME} {APP_VERSION}")
app.geometry("1200x640")
tb.Style("darkly")
Enter fullscreen mode Exit fullscreen mode

Explanation:
We use a Queue for thread-safe communication between background threads (sync engine) and the UI.

3️⃣ Folder Selection & Settings

Add folder selection for source and target directories:

source_folder = tb.StringVar()
target_folder = tb.StringVar()

def browse_source():
    folder = tk.filedialog.askdirectory()
    if folder:
        source_folder.set(folder)

def browse_target():
    folder = tk.filedialog.askdirectory()
    if folder:
        target_folder.set(folder)
Enter fullscreen mode Exit fullscreen mode

Explanation:
Tkinter’s filedialog.askdirectory() allows users to pick folders for synchronization.

4️⃣ Logging & Progress Updates

We use a Text widget and Progressbar for live updates:

log_text = tk.Text(app, height=10, state="disabled")
log_text.pack(fill="both", expand=True)

progress = tb.Progressbar(app, bootstyle="success-striped")
progress.pack(fill="x", padx=10, pady=5)

def log(msg):
    ui_queue.put(("log", msg))

def update_progress(value):
    ui_queue.put(("progress", value))
Enter fullscreen mode Exit fullscreen mode

Explanation:
Logs are queued to avoid thread conflicts, and progress updates keep the user informed.

5️⃣ File Hashing & Filtering

import hashlib, os

filter_ext = tb.StringVar(value="")

def hash_file(path):
    md5 = hashlib.md5()
    with open(path, "rb") as f:
        for chunk in iter(lambda: f.read(4096), b""):
            md5.update(chunk)
    return md5.hexdigest()

def allowed_file(file):
    ext = filter_ext.get().strip()
    if not ext:
        return True
    allowed = [e.strip().lower() for e in ext.split(",")]
    return os.path.splitext(file)[1].lower() in allowed
Enter fullscreen mode Exit fullscreen mode

Explanation:

hash_file ensures file integrity during sync

allowed_file enables extension-based filtering (.txt,.pdf,.py)

6️⃣ Multi-Threaded File Sync
import shutil
from concurrent.futures import ThreadPoolExecutor

files_synced = 0
bytes_copied = 0

def sync_file(src, dst):
    global files_synced, bytes_copied
    os.makedirs(os.path.dirname(dst), exist_ok=True)
    if not os.path.exists(dst) or os.path.getmtime(src) > os.path.getmtime(dst):
        shutil.copy2(src, dst)
        files_synced += 1
        bytes_copied += os.path.getsize(src)
        log(f"βœ” Synced: {os.path.basename(src)}")

def full_sync():
    src = source_folder.get()
    dst = target_folder.get()
    file_list = []
    for root, dirs, files in os.walk(src):
        for f in files:
            if allowed_file(f):
                file_list.append(os.path.join(root, f))

    executor = ThreadPoolExecutor(max_workers=6)
    for src_file in file_list:
        rel = os.path.relpath(src_file, src)
        dst_file = os.path.join(dst, rel)
        executor.submit(sync_file, src_file, dst_file)
    executor.shutdown(wait=True)
Enter fullscreen mode Exit fullscreen mode

Explanation:

Multi-threaded copy improves performance

Only copies changed files using mtime

7️⃣ Optional ZIP Backup & Encryption

import zipfile
from cryptography.fernet import Fernet

encrypt_backup = tb.BooleanVar(value=False)
zip_backup = tb.BooleanVar(value=False)

def create_zip_backup(folder):
    zip_path = f"{folder}_backup.zip"
    with zipfile.ZipFile(zip_path, "w", zipfile.ZIP_DEFLATED) as z:
        for root, dirs, files in os.walk(folder):
            for f in files:
                file_path = os.path.join(root, f)
                z.write(file_path, os.path.relpath(file_path, folder))
    log(f"πŸ“¦ Backup created: {zip_path}")

def encrypt_file(path):
    key = Fernet.generate_key()
    fernet = Fernet(key)
    with open(path, "rb") as f:
        encrypted = fernet.encrypt(f.read())
    with open(path + ".enc", "wb") as f:
        f.write(encrypted)
Enter fullscreen mode Exit fullscreen mode

Explanation:
Optional ZIP archives and encryption secure your backups.

8️⃣ Real-Time Monitoring

from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler

class SyncHandler(FileSystemEventHandler):
    def on_modified(self, event):
        if not event.is_directory and allowed_file(event.src_path):
            dst = os.path.join(target_folder.get(), os.path.relpath(event.src_path, source_folder.get()))
            sync_file(event.src_path, dst)

observer = Observer()
observer.schedule(SyncHandler(), source_folder.get(), recursive=True)
observer.start()
Enter fullscreen mode Exit fullscreen mode

Explanation:

Uses watchdog to detect file changes

Syncs immediately to the target folder

9️⃣ Running the App

app.after(100, process_ui_queue)
app.mainloop()
Enter fullscreen mode Exit fullscreen mode

Explanation:

process_ui_queue handles logs, progress, and stats updates

mainloop() starts the Tkinter GUI

βœ… Final Notes

FileSync PRO v4.0.0 Features:

⚑ Real-time folder monitoring

πŸš€ Multi-threaded high-performance copy

🧠 Hash verification

πŸ“¦ ZIP backup with optional encryption

πŸ—‘ Mirror mode & extension filtering

πŸ“Š Sync analytics dashboard

Download: GitHub Release v4.0.0

Top comments (0)