Rsync Command Generator & Transfer Builder

Construct production-ready rsync commands with safe dry-run flags, SSH identity keys, port forwarding, exclusions, and bandwidth controls.

Transfer Presets:
Transfer Flags & Options:

How to Use Rsync Safely

1

Configure Paths & Options

Enter your source and destination paths, specify custom SSH ports or keys, and select desired flags.

2

Always Run Dry-Run First

Execute the simulated -n command to preview files that will be copied or removed before committing changes.

3

Execute Live Sync

Run the production command with resume protection (-P) and real-time progress indicators.

Tool Options

Trailing Slash Detection

Visually alerts you whether rsync will copy the directory contents (/dir/) or the parent folder (/dir).

SSH Key & Port Customization

Formats -e "ssh -p port -i key" to simplify transfers across custom SSH port numbers and AWS pem keys.

Automatic Dry-Run Generation

Produces a safe dry-run (-n) counterpart for every command to safeguard against accidental data deletion.

Your Data Privacy

Web Tool
Privacy-First Architecture
Most of our web tools process your data entirely in-browser. Where server processing is technically required, payloads are evaluated statelessly in-memory and are never stored, saved, or logged.
REST API
Stateless In-Memory Processing
When you use our API endpoints, your requests are processed strictly in-memory without persistent database storage, disk logging, or data retention.
Want to learn more about how we safeguard your information and infrastructure?
Read our full Privacy Policy for detailed security standards, data retention principles, and compliance guarantees.

What does the Rsync Command Generator & Transfer Builder do?

The Rsync Command Generator creates syntax-checked rsync commands for local backups and remote server transfers over SSH. It constructs -e "ssh ..." flags for non-standard ports and identity keys, applies glob exclude rules, generates a -n dry-run simulation command, and highlights whether the source path trailing slash copies directory contents or the folder itself.

Core Concepts

Understanding key rsync behaviors prevents data loss and accidental duplicate nesting:

  • The Trailing Slash Rule: A trailing slash on the source directory (/var/www/html/) instructs rsync to copy the contents of the folder into the destination. Omitting the trailing slash (/var/www/html) instructs rsync to copy the folder itself as a sub-directory inside the destination.
  • Delta-Transfer Algorithm: Unlike traditional cp or scp, rsync calculates checksum differences and transfers only modified byte chunks, significantly reducing bandwidth and transfer times.
  • Resumable Partial Transfers (-P / --partial --progress): Keeps partially transferred files if a connection drops, enabling seamless resume of multi-gigabyte transfers without restarting from byte zero.

How to use the tool?

  1. Enter Source and Destination Paths: Specify local directory paths (e.g. /var/www/html/) or remote SSH targets in user@hostname:/remote/path/ format.
  2. Configure Remote SSH Settings:
    • SSH Port: Specify non-standard SSH ports (e.g., 2222). The generator automatically formats -e "ssh -p 2222".
    • SSH Identity Key: Provide the absolute or relative path to your private key file (e.g. ~/.ssh/id_rsa or ~/.ssh/deploy_key.pem).
  3. Select Transfer Flags & Options:
    • -a (Archive mode): Preserves file permissions, symlinks, timestamps, ownership, and recurses into subdirectories.
    • -v (Verbose) & -h (Human-readable): Prints transferred file names and human-friendly sizes (KB, MB, GB).
    • -z (Compress): Compresses network data in transit over WAN or slow connections.
    • -P (Progress & Partial): Displays real-time transfer progress and retains partially downloaded files.
    • --delete: Deletes destination files that no longer exist in the source directory (creating an exact mirror).
    • Exclude Patterns: Enter file and folder patterns (one per line, e.g. node_modules/, .git/, *.log) to exclude from transfer.
  4. Copy Dry-Run Command First: Always run the generated dry-run command (-n) first in your terminal to verify which files will be copied or removed before executing the production command.

Related Developer Utilities

If you are managing Linux servers, deployments, or SSH access, explore these complementary Blueutils developer utilities:

REST API Integration

Blueutils provides a free REST API endpoint (POST https://blueutils.com/api/linux/rsync-generator) to programmatically build optimized rsync command lines with automatic dry-run (-n) safety flags, SSH keys/ports, and exclusions.

API Request Parameters

Name Type Description Example
sourcePath String Source local or remote directory/file path. "/var/www/html/"
destPath String Target destination directory or remote endpoint. "ubuntu@54.161.226.140:/var/www/backup/"
archive Boolean Whether to enable archive mode (-a). Defaults to true. true
verbose Boolean Whether to enable verbose file transfer output (-v). true
humanReadable Boolean Whether to format numbers in human-readable units (-h). true
compress Boolean Whether to compress stream data during network transfer (-z). true
progress Boolean Whether to show progress and enable partial transfer resume (-P). true
delete Boolean Whether to delete extraneous files from destination (--delete). false
sshPort Number/String Custom remote SSH port number (e.g. 2222). 22
sshKey String Path to private SSH key identity file (-i). "~/.ssh/id_rsa"
bwlimit String I/O bandwidth rate limit (e.g. 10M or 5000). "10M"
excludes Array/String Excluded file glob patterns or multiline text. ["node_modules", ".git"]

API Request Payload Examples

cURL

curl -X POST https://blueutils.com/api/linux/rsync-generator \
  -H "Content-Type: application/json" \
  -d '{
    "sourcePath": "/var/www/html/",
    "destPath": "ubuntu@54.161.226.140:/var/www/backup/",
    "archive": true,
    "verbose": true,
    "compress": true,
    "delete": true,
    "sshPort": 22
  }'

Python

import requests

url = "https://blueutils.com/api/linux/rsync-generator"
payload = {
    "sourcePath": "/var/www/html/",
    "destPath": "ubuntu@54.161.226.140:/var/www/backup/",
    "archive": True,
    "verbose": True,
    "compress": True,
    "delete": True,
    "sshPort": 22
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())

Java

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
    public static void main(String[] args) throws Exception {
        String jsonPayload = """
            {
                "sourcePath": "/var/www/html/",
                "destPath": "ubuntu@54.161.226.140:/var/www/backup/",
                "archive": true,
                "verbose": true,
                "compress": true,
                "delete": true,
                "sshPort": 22
            }
            """;

        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://blueutils.com/api/linux/rsync-generator"))
            .header("Content-Type", "application/json")
            .POST(HttpRequest.BodyPublishers.ofString(jsonPayload))
            .build();

        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}

API Response Parameters

Name Type Description Example
isValid Boolean Indicates whether command generation succeeded. true
prodCommand String The fully compiled production rsync command. "rsync -avhz --delete /src/ /dest/"
dryRunCommand String Safe simulation command with dry-run (-n) enabled. "rsync -avhzn --delete /src/ /dest/"
trailingSlashNote String Explanation of trailing slash behavior for source path. "Source has trailing slash..."
flagDescriptions Array Structured list of individual flags and their meanings. [{"flag": "-a", "desc": "..."}]

API Response Payload Examples

Success Response (HTTP 200 OK)

{
  "isValid": true,
  "prodCommand": "rsync -avhz --delete /var/www/html/ ubuntu@54.161.226.140:/var/www/backup/",
  "dryRunCommand": "rsync -avhzn --delete /var/www/html/ ubuntu@54.161.226.140:/var/www/backup/",
  "trailingSlashNote": "Source has trailing slash: rsync will copy the CONTENTS of the directory into destination.",
  "flagDescriptions": [
    { "flag": "-a", "desc": "Archive mode (preserves permissions, timestamps, owner, symlinks, and recurses directories)" },
    { "flag": "-v", "desc": "Verbose output detailing transferred files" },
    { "flag": "-h", "desc": "Output numbers in human-readable format (e.g. KB, MB, GB)" },
    { "flag": "-z", "desc": "Compress file data during transfer over network" },
    { "flag": "--delete", "desc": "Delete extraneous files from destination that do not exist in source" }
  ]
}

Validation Failure Response (HTTP 400 Bad Request)

{
  "isValid": false,
  "error": "Source path cannot be empty."
}

Rate Limit Exceeded Response (HTTP 429 Too Many Requests)

{
  "error": "API rate limit exceeded. Please wait or contact support@blueutils.com."
}

Why use an API to generate Rsync commands?

Integrating the Rsync Generator API into CI/CD pipelines, DevOps scripts, or automated agent workflows provides several practical advantages:

  • Rapid Script Validation: Enables developers and infrastructure engineers to programmatically generate and verify complex transfer command lines across diverse deployment environments without manual syntax checking.
  • Optimized Token Efficiency for AI Agents: Offloading command formatting to an external API significantly cuts prompt and completion token consumption for autonomous agents.
  • Deterministic Accuracy Without Hallucinations: Language models can occasionally misformat subtle CLI flags (such as trailing slashes, nested SSH identity key arguments, or exclude glob escaping). Delegating generation to a deterministic API guarantees 100% syntactically correct commands every time without token overhead.

Native Usage

How to perform file synchronizations and directory mirroring locally and natively without external dependencies:

Windows (CMD / PowerShell / Robocopy)

On Windows, native robocopy provides mirror and delta synchronization functionality equivalent to rsync:

# Preview mirror synchronization (Dry-Run / List Only)
robocopy "C:\Source" "D:\Destination" /E /MIR /L /NP

# Execute mirror synchronization (copies changes, deletes destination orphans)
robocopy "C:\Source" "D:\Destination" /E /MIR /NP /R:2 /W:5

Linux / Unix (Bash / Rsync)

# 1. Preview transfer in dry-run mode (no files modified)
rsync -avhzn --progress --delete /var/www/html/ user@remote-host:/var/www/backup/

# 2. Execute live synchronization over custom SSH port with key
rsync -avhzP --delete -e "ssh -p 2222 -i ~/.ssh/id_ed25519" /var/www/html/ user@remote-host:/var/www/backup/

Python

Using Python's standard library subprocess or shutil for directory mirroring:

import subprocess

def run_rsync(source, dest, dry_run=True):
    cmd = ["rsync", "-avhzP", "--delete"]
    if dry_run:
        cmd.append("-n")
    cmd.extend([source, dest])
    
    result = subprocess.run(cmd, capture_output=True, text=True)
    print("STDOUT:", result.stdout)
    if result.stderr:
        print("STDERR:", result.stderr)

# Dry run test
run_rsync("/var/www/html/", "/backup/html/", dry_run=True)

Java

Using Java ProcessBuilder to execute native rsync transfers safely:

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class RsyncRunner {
    public static void main(String[] args) {
        ProcessBuilder pb = new ProcessBuilder(
            "rsync", "-avhzPn", "--delete", "/var/www/html/", "/backup/html/"
        );
        pb.redirectErrorStream(true);

        try {
            Process process = pb.start();
            try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
                String line;
                while ((line = reader.readLine()) != null) {
                    System.out.println(line);
                }
            }
            int exitCode = process.waitFor();
            System.out.println("Exit code: " + exitCode);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Frequently Asked Questions (FAQ)

Why does the trailing slash matter in rsync?

A trailing slash on the source path (/src/) copies the *contents* of the directory into the destination. Omitting the trailing slash (/src) copies the *directory itself* into the destination.

How do I safely test an rsync command before running it?

Always run with -n (or --dry-run) first. This simulates the transfer and shows every file that would be copied or deleted without modifying any destination data.

How do I resume an interrupted file transfer?

Include -P (or --partial --progress). If the network connection drops, rsync preserves the partially transferred file so restarting the command resumes transfer from where it stopped.

Rate Limits

UI Limits
100 uses per 15 minutes
Max payload size: 5 MB
API Limits
5 requests per 60 minutes
Max payload size: 256 KB
Need higher API rate limits, increased payload sizes, or custom developer solutions?
Contact our engineering team at support@blueutils.com for custom rate limit increases, higher quota allocations, or tailored enterprise integrations.