Skip to main content

GUI tool to generate a bash script for one-way, no-deletion NAS sync using rsync and lsyncd

Project description

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.

PyPI version PyPI downloads License GitHub stars GitHub forks

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nas_sync_script_builder-0.6.0.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nas_sync_script_builder-0.6.0-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

Details for the file nas_sync_script_builder-0.6.0.tar.gz.

File metadata

  • Download URL: nas_sync_script_builder-0.6.0.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for nas_sync_script_builder-0.6.0.tar.gz
Algorithm Hash digest
SHA256 144b7cfbe913f4d86d3b60fa510ab8e36c1df644f7e3ff730ebda945baa5bcc6
MD5 cc9f8ebf520d8b586e28406e2471a7e3
BLAKE2b-256 20ef469bc9df4baef949b1ed367d8ebd1eed6b184cebfb47f6f801caff9e2522

See more details on using hashes here.

File details

Details for the file nas_sync_script_builder-0.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for nas_sync_script_builder-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 990e9d09169f814627a08581ba01f179e063837a9b2e303a7441c2f7e8e6635b
MD5 30cc5ee19d30107676805c8b712347ee
BLAKE2b-256 c74e0deca21bf53f1abf30db064618de68c0d13ab9154c5d82404ffc50cf0ee3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page