Skip to content

Batyan45/wwsync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wwsync

A simple, interactive wrapper around rsync designed for developers who code locally but run on a remote server. It manages configurations automatically and prevents accidental data loss on the server.

Features

  • Zero-Config Start: Just run wwsync <server> -s in your project folder. It will ask for details once and remember them.
  • Multiple Servers: Support for distinct configurations (e.g., production, staging, dev-server).
  • Safe Mode (-s / --safe): Standard execution uploads files but never deletes anything on the server (preserving logs, build artifacts, etc.).
  • Interactive Full Sync (-f / --full): The -f flag mirrors the local directory. It performs a "dry run" first, shows you exactly which files will be deleted, and asks for confirmation.
  • Sync All (-a / --all): Syncs all mappings across all servers in one command. Requires --safe or --full. Asks for confirmation before each mapping.
  • Auto Accept (--auto_accept): Skips all confirmations in --full and --all modes.
  • Remote Run (-r): Automatically SSH into the server, cd to the project folder, and optionally execute a startup command (e.g. conda activate).
  • Exclusions: Easy management of ignored files (node_modules, .git, .env).
  • General Excludes: Define exclusion patterns once in general_excludes — they apply to all mappings on all servers automatically.
  • Artifacts Download (-d / --download): Downloads only new remote files into .wwsync_<server>_artifacts inside your project. Changed files are listed as warning and are not downloaded.

Installation

  1. Download the script:
curl -o wwsync -L https://github.com/Batyan45/wwsync/releases/latest/download/wwsync
# OR just copy the python code into a file named 'wwsync'
  1. Make it executable:
chmod +x wwsync
  1. Move it to your path:
sudo mv wwsync /usr/local/bin/

Usage

1. Basic Sync (Safe Mode)

Run this command inside your project folder:

wwsync my-server -s
  • If this is your first time, it will ask for the user@ip and the remote path.
  • It will sync changes to the server.
  • It will NOT delete files on the server that are missing locally.

2. Full Sync (Mirroring)

If you renamed files or cleaned up your local folder and want the server to match exactly:

wwsync my-server -f
  • It calculates differences.
  • It displays a list of files to be deleted (e.g., deleting logs/old.log).
  • It asks for y/n confirmation before deleting anything.

3. Remote Run

To jump into the remote server directory (and optionally run a command):

wwsync my-server -r
  • Connects via SSH and cds to the configured remote path.
  • If a run_command is configured (e.g. source .env), it executes it first.
  • Leaves you in an interactive shell.

Combine with sync:

wwsync my-server -s -r

4. Sync All Mappings

To sync all configured mappings across all servers:

# Safe sync all
wwsync -a -s

# Full sync all (with confirmations)
wwsync -a -f

# Full sync all without confirmations
wwsync -a -f --auto_accept
  1. Syncs files (Safe mode).
  2. Starts remote session.

5. Download Remote Artifacts

wwsync my-server -d
  • Creates/overwrites .wwsync_my-server_artifacts in your project directory.
  • Downloads only files that are new on remote.
  • If remote also has changed files, prints a warning list and skips those files.
  • If the artifacts folder already exists, asks for confirmation before deleting it.

Configuration

The configuration is stored in ~/.wwsync in JSON format. You can edit it manually if needed.

Example structure:

{
    "general_excludes": [".git", ".DS_Store", "__pycache__"],
    "servers": {
        "production": {
            "host": "root@192.168.1.50",
            "shell": "zsh",
            "mappings": [
                {
                    "local": "/Users/dev/my-project",
                    "remote": "/var/www/html/api",
                    "excludes": ["node_modules", ".env"],
                    "artifact_excludes": ["*.tmp", "*.cache"],
                    "run_command": "source .env; conda activate myenv"
                }
            ]
        }
    }
}
  • general_excludes — patterns listed here are merged with every mapping's excludes on every server. Duplicates are removed automatically. This is useful for patterns like .git, .DS_Store, __pycache__ that you always want to exclude.
  • excludes (per mapping) — additional patterns specific to a particular folder.

Requirements

  • Python 3+
  • rsync installed on both local machine and remote server.
  • SSH access to the remote server.

About

A simple, interactive wrapper around rsync designed for developers who code locally but run on a remote server. It manages configurations automatically and prevents accidental data loss on the server.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages