Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

rsync

БесплатноБез исполняемых скриптовНе проверен

rsync copies and synchronizes files locally or over SSH, sending only the parts that changed. Use when someone asks to "copy files to a server", "sync two…

TerminalSkillsот TerminalSkills★ 221 звезда на GitHub

Об этом скилле

rsync

Overview

rsync compares source and destination and transfers only what differs (a changed file is sent as a delta). It preserves permissions, times and symlinks with -a, talks to remote hosts through SSH by default, and is the usual tool for deployments, mirrors and snapshot backups. The current release is 3.5.1 (September 2026, protocol 33); 3.5.0 fixed 33 security issues in path and symlink handling, so keep both ends updated (brew install rsync on macOS, since the bundled binary can be an older or different implementation; check rsync --version).

Instructions

1. Copy and sync

rsync -a --info=progress2 ./dist/ [email protected]:/var/www/shop/   # local to remote
rsync -a [email protected]:/var/log/shop/ ./logs/                     # remote to local
rsync -a --mkpath ./site/ /backups/daily/site/                               # create missing destination dirs (3.2.3+)

-a is archive mode (recursive, keeps permissions, times, symlinks, owner and group when allowed). Add -z only for slow links with compressible data; it wastes CPU on LAN transfers and on already compressed files (images, archives). -h prints human-readable sizes.

Trailing slash on the source decides what is copied: src/ copies the contents into the destination, src copies the directory itself as dest/src. A trailing slash on the destination does not matter.

2. Preview before changing anything

$ rsync -an --itemize-changes --exclude=node_modules app/ mirror/
cd+++++++++ ./
cd+++++++++ src/
>f+++++++++ src/a.txt

-n (dry run) with -i lists exactly what would happen. +++++++++ means new, *deleting means a file removed from the destination.

3. Mirror, exclude, filter

rsync -a --delete --exclude='node_modules' --exclude='.git' --exclude='.env' ./build/ [email protected]:/var/www/shop/
rsync -a --exclude-from=.rsync-ignore ./app/ /backups/app/
rsync -a --files-from=changed.txt ./app/ [email protected]:/srv/app/   # paths relative to ./app/

--delete removes destination files that no longer exist in the source, so run it with -n first. Exclude patterns are matched relative to the transfer root; anchor with a leading slash (--exclude='/.env').

4. Remote options

rsync -a -e "ssh -p 2222 -i ~/.ssh/deploy_ed25519" ./dist/ [email protected]:/var/www/shop/
rsync -a --rsync-path="sudo rsync" ./conf/ [email protected]:/etc/shop/    # needs passwordless sudo for rsync there
rsync -a --partial --append-verify --info=progress2 big.iso [email protected]:/vol/iso/   # resume a big file
rsync -a --bwlimit=5m ./media/ [email protected]:/vol/media/            # 5 MiB/s; plain number = KiB/s

--partial keeps an interrupted file so the next run continues it. rsync over SSH is encrypted; the rsync:// daemon protocol is not. Use a restricted key and command= with rrsync in authorized_keys for unattended jobs.

5. Snapshot backups with hard links

Each run produces a complete-looking directory, but unchanged files are hard links to the previous snapshot, so they cost no space:

#!/usr/bin/env bash
set -euo pipefail
SRC=/srv/shop/
DEST=/backups/shop
TODAY=$(date +%F)
mkdir -p "$DEST"
rsync -a --delete --exclude='/cache/' --link-dest="$DEST/latest" "$SRC" "$DEST/$TODAY/"
ln -sfn "$DEST/$TODAY" "$DEST/latest"

Give --link-dest an absolute path. On the very first run latest does not exist and rsync prints a --link-dest arg does not exist warning but still makes a full copy.

Examples

Example 1: "Deploy the build to the server without touching the uploads folder"

npm run build
rsync -a --delete --exclude='/uploads/' --exclude='/.env' -n -i ./dist/ [email protected]:/var/www/shop/
rsync -a --delete --exclude='/uploads/' --exclude='/.env' ./dist/ [email protected]:/var/www/shop/
ssh [email protected] "sudo systemctl reload nginx"

The first command is the dry run: review the *deleting lines. Excluded paths are also protected from --delete, so uploads/ and .env on the server survive.

Example 2: "Nightly backup that keeps 14 days"

Use the script from step 5 from cron (15 2 * * * /usr/local/bin/shop-backup.sh), then prune: find /backups/shop -maxdepth 1 -type d -name '20*' -mtime +14 -exec rm -rf {} +. Check the saving with du -sh /backups/shop/*: the second snapshot only counts files that changed (verified: unchanged src/a.txt shared one inode across both snapshots, the modified file got a new one).

Guidelines

  • Always dry-run (-n -i) before --delete, and never point --delete at a path built from an unchecked variable (an empty $DEST can mean /).
  • Quote paths with spaces; a remote path with spaces needs quoting for both shells.
  • -a keeps owner and group only when run as root on the receiver; add -A -X for ACLs and extended attributes and -H for hard links inside the tree.
  • --checksum c
Полный SKILL.md на GitHub

Установить rsync в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

_scores.json

FAQ

Что делает скилл rsync?

rsync copies and synchronizes files locally or over SSH, sending only the parts that changed. Use when someone asks to "copy files to a server", "sync two directories", "mirror a folder", "make incremental backups with hard links", "deploy a build to a remote host", "resume a big transfer" or "exclude node_modules when copying".

Как установить скилл rsync?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл rsync запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить rsync с