WatchSync is a tool for synchronizing files when they are created or modified across different storage locations. A file can also be a local directory that, when detected as modified or created, is synchronized with the configured storage locations. A storage location can be a local or remote directory where a copy of the files will be sent.
The purpose of this tool is to have a backup of files in different storage locations to avoid losing important information. It is a file replication solution that is very easy to configure and use.
- Automatic synchronization of files and directories.
- Support for multiple local and remote storage locations.
- Easy to configure and use.
- Uses
rsyncfor efficient file synchronization.
WatchSync uses rsync for file synchronization, so it must be installed on the system. On Debian-based systems, it can be installed with the following command:
sudo apt install rsyncInstall the package with pip:
pip install watchsyncClone the repository:
git clone https://github.com/rlizana/watchsync.git
cd watchsyncInstall dependencies and build the package:
poetry installInstall the package globally:
poetry build
pip install dist/watchsync-*.whlWatchSync uses a daemon to monitor file changes and synchronize them with storage locations. A storage location can be a local directory, a remote server, or a git repository.
To start the daemon, use watchsync start, and to stop it, use watchsync stop. If you want to restart the daemon to reread configuration changes, use watchsync reload.
To manage storage locations, use the command watchsync store.
You can list storage locations with watchsync store list, add a storage location with watchsync store add NAME TYPE PATH, and remove one with watchsync store del NAME.
Alternatively, you can edit the configuration file ~/.config/watchsync/config.yaml to add storage locations manually, but note that the daemon will not pick up changes until you restart it after making modifications.
To manage the files being monitored, use the command watchsync file.
You can list files with watchsync file list, add a file with watchsync file add PATH, and remove a file with watchsync file del PATH.
This project is developed using TDD. Therefore, any changes or improvements to be added must first include a failing unit test, and then the necessary code must be written to make the test pass.
Install the development dependencies:
poetry install --with dev
poetry run pre-commit installTo run unit tests:
poetry run python3 -m unittest discover -s testsWith coverage:
poetry run coverage run -m unittest discover -s tests
poetry run coverage reportOr you can run with one of these commands
poetry run watchsync
poetry run python3 -m watchsync
poetry run python3 -m watchsync.daemon.watchsyncdYou can use docker to test the tool. The following command will build the image and run the tests:
docker build -t watchsync-test .
docker run --rm watchsync-testIf you are developing, you can use the following command to mount the current directory in the container and run the tests:
docker run --rm \
-v $(pwd)/watchsync:/watchsync/watchsync \
-v $(pwd)/tests:/watchsync/tests \
watchsync-testOtherwise, you can run the container interactively and run the tests inside it:
docker run -it --name watchsync-dev \
-v $(pwd)/watchsync:/watchsync/watchsync \
-v $(pwd)/tests:/watchsync/tests \
watchsync-test /bin/bash
poetry run python3 -m unittest discover -s testsYou can also run a specific test with the following command:
docker run -it --name watchsync-dev \
-v $(pwd)/watchsync:/watchsync/watchsync \
-v $(pwd)/tests:/watchsync/tests \
watchsync-test /bin/bash
poetry run python3 -m unittest tests.test_watchsync.TestTreytuxControl.test_daemon_restart