Metadata-Version: 2.4
Name: nas-sync-script-builder
Version: 0.5.0
Summary: GUI tool to generate a bash script for one-way, no-deletion NAS sync using rsync and lsyncd
Author: Jinjinov
Maintainer: Jinjinov
License: MIT License
        
        Copyright (c) 2026 Jinjinov
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Repository, https://github.com/Jinjinov/nas-sync-script-builder
Project-URL: Issues, https://github.com/Jinjinov/nas-sync-script-builder/issues
Project-URL: Releases, https://github.com/Jinjinov/nas-sync-script-builder/releases
Keywords: nas,rsync,lsyncd,gui,backup
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: POSIX :: Linux
Classifier: Topic :: System :: Archiving :: Backup
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: PySide6
Requires-Dist: Jinja2
Requires-Dist: PyYAML
Requires-Dist: pydbus
Requires-Dist: PyGObject
Dynamic: license-file

# 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](https://img.shields.io/pypi/v/nas-sync-script-builder.svg)](https://pypi.org/project/nas-sync-script-builder)
[![PyPI downloads](https://img.shields.io/pypi/dm/nas-sync-script-builder.svg)](https://pepy.tech/project/nas-sync-script-builder)
[![License](https://img.shields.io/github/license/Jinjinov/nas-sync-script-builder.svg)](https://github.com/Jinjinov/nas-sync-script-builder/blob/main/LICENSE)
[![GitHub stars](https://img.shields.io/github/stars/Jinjinov/nas-sync-script-builder.svg)](https://github.com/Jinjinov/nas-sync-script-builder/stargazers)
[![GitHub forks](https://img.shields.io/github/forks/Jinjinov/nas-sync-script-builder.svg)](https://github.com/Jinjinov/nas-sync-script-builder/network)

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
```
