nas-sync-script-builder
Python GUI tool to generate a bash script for one-way, no-deletion NAS sync using rsync and lsyncd.
The script is idempotent and safe to re-run.
The script sets up a one way sync with no deletions, not a mirror.
Features:
- Automatic detection of eligible local partitions via UDisks2 (D-Bus)
- One-way sync only (local → NAS)
- No deletions on destination
- Initial sync using rsync --update
- Real-time sync via lsyncd
- Safe mount handling with systemd automounts
- Persistent credentials handling
- Configurable exclude patterns
Requirements
System (Linux)
- systemd
- udisks2
- CIFS/SMB-compatible NAS (e.g. Synology)
The generated script installs these automatically:
- lsyncd
- cifs-utils
Running the GUI
Install:
pip install nas-sync-script-builder
Run:
nas-sync-script-builder
This opens the GUI where you can:
- Review detected partitions
- Edit filesystem types if needed
- Configure NAS connection details
- Customize exclude patterns
- Adjust local → NAS directory mappings
Click Generate to:
- Save settings to
nas_sync_config.yaml - Generate the bash script
nas-sync.sh
Running the CLI
You can also use it without the GUI:
nas-sync-script-builder --cli --config path/to/config.yaml --output path/to/nas-sync.sh
--cli runs in headless mode
Optional:
--config specify the yaml config file (default: nas_sync_config.yaml)
--output specify the output bash file (default: nas-sync.sh)
If the config file exists, the bash script is generated.
If the config file doesn't exist, a default config file is generated.
Running the Generated Script
sudo ./nas-sync.sh
The script will:
- Install required system packages
- Prompt for the NAS password and create
/etc/samba/credentials - Create mount points for local disks and NAS shares
- Configure mounts in
/etc/fstab - Perform an initial sync
- Configure lsyncd in
/etc/lsyncd/lsyncd.conf.lua - Configure lsyncd systemd dependencies in
/etc/systemd/system/lsyncd.service.d/override.conf - Configure lsyncd log rotation in
/etc/logrotate.d/lsyncd - Increase inotify max_user_watches in
/etc/sysctl.d/99-inotify.conf - Enable and start lsyncd
Development
Use a virtual environment:
python3 -m venv venv
source venv/bin/activate
Install Python dependencies:
pip install PySide6 Jinja2 PyYAML pydbus
System Dependencies for D-Bus (pydbus / PyGObject):
Required by PyGObject:
sudo apt install libgirepository-2.0-dev libcairo2-dev pkg-config
Required by pydbus:
pip install PyGObject
Editable install:
pip install -e .
Install the build tools:
pip install build twine
Create the distribution files:
python -m build
Check the distribution files:
twine check dist/*
Upload to TestPyPI:
twine upload --repository testpypi dist/*
https://test.pypi.org/project/nas-sync-script-builder/
Install from TestPyPI:
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ nas-sync-script-builder
Upload to PyPI:
twine upload dist/*
https://pypi.org/project/nas-sync-script-builder/
Install from PyPI:
pip install nas-sync-script-builder
Check version:
pip show nas-sync-script-builder
Metadata
Release files for nas-sync-script-builder 0.7.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| nas_sync_script_builder-0.7.0.tar.gz | 13.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nas_sync_script_builder-0.7.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 28.5 kB
Release files / nas_sync_script_builder-0.7.0.tar.gz
| Download URL | nas_sync_script_builder-0.7.0.tar.gz |
|---|---|
| Size | 13.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
85f6916ed78b146cd48119318680b851ca951cdca4657dfef2731041120f6a43
|
|
BLAKE2b-256 checksum How to use checksums |
fc8b376837ef42a644b2bad28cf54ebb590f5c3edba6cc222c87f5745bb53206
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Release files / nas_sync_script_builder-0.7.0-py3-none-any.whl
| Download URL | nas_sync_script_builder-0.7.0-py3-none-any.whl |
|---|---|
| Size | 14.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bc8f191c465743acf2a024e7f284a978c491106020fdfa284943e7c095d53385
|
|
BLAKE2b-256 checksum How to use checksums |
eb7c0a77c458d22048ee5189af55f3c00e6dc375c14c49b7f0890e84c6092d21
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|