Skip to main content

peter-sync

Bidirectional folder sync from the command line. Define folder pairs, save them as JSON, and keep both sides up to date.

Install

pip install peter-sync

From a local checkout:

python -m pip install -e ".[dev]"

Usage

Open the interactive menu:

peter-sync

Or use subcommands:

peter-sync add notes ~/Documents/Notes ~/Dropbox/Notes
peter-sync add code ~/src/app ~/backup/app --exclude node_modules --exclude .git
peter-sync list
peter-sync exclude code
peter-sync exclude code --add dist
peter-sync exclude code --remove .git
peter-sync exclude code --set node_modules dist
peter-sync sync notes
peter-sync sync
peter-sync watch notes
peter-sync watch --interval 5
peter-sync remove notes

watch is a long-running process. It polls the folders on an interval (default 2 seconds), reloads settings each cycle, and keeps copying or deleting until you press Ctrl+C. Omit the pair name to watch every saved pair.

Settings are stored at ~/.peter-sync/settings.json unless you pass --settings.

Example settings file:

{
  "pairs": [
    {
      "name": "notes",
      "left": "/Users/you/Documents/Notes",
      "right": "/Users/you/Dropbox/Notes",
      "snapshot": ["todo.md"],
      "exclude": ["node_modules", ".git"]
    }
  ]
}

How sync works

  • New files are copied to the other folder.
  • When both sides have the same file, the newer modification time wins.
  • Identical files are left alone.
  • If both files differ and have the same mtime, the pair is reported as a conflict and left unchanged.
  • Each pair can exclude folders. A bare name such as node_modules is skipped anywhere in the tree. A relative path such as build/tmp is skipped only at that location. Excluded folders are not copied, updated, or deleted.
  • After the first sync, deleting a file on one side deletes it on the other. The last file list is stored in the settings JSON.

Publish to PyPI

  1. Create an API token at https://pypi.org/manage/account/token/
  2. Build and upload:
python -m pip install build twine
python -m build
python -m twine upload dist/*

Or publish a GitHub Release and use .github/workflows/publish.yml with trusted publishing (or a PYPI_API_TOKEN repository secret).

Develop

python -m pip install -e ".[dev]"
pytest

Download files

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

Source Distribution

peter_sync-0.1.1.tar.gz (13.8 kB view details)

Uploaded Source

Built Distribution

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

peter_sync-0.1.1-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file peter_sync-0.1.1.tar.gz.

File metadata

  • Download URL: peter_sync-0.1.1.tar.gz
  • Upload date:
  • Size: 13.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.1

File hashes

Hashes for peter_sync-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5eeabce6e6d6d41c2db484d713f4dd89ede4b57ad1a18fbd2be3e5caa272909c
MD5 f9c72996e0cb490b2e246da10a58a7c8
BLAKE2b-256 29c843b64f5bbf8793b63a4d84d947fc74d4897a15b3a4e7e4bb495c0584f993

See more details on using hashes here.

File details

Details for the file peter_sync-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: peter_sync-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.1

File hashes

Hashes for peter_sync-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 12b1e251d149d8cecd5962fd4ac73fb19d82efa99f11af58b485baef6f9b6bf6
MD5 43e5f38f88f06b3c24b90aa7b80d5cee
BLAKE2b-256 6062a47e111e6d2f764be1977a85dacf7c9034833de3d7f330342e379a09dcbe

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 files

0.1.0

2 files

Supported by

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