Przejdź do treści
Biblioteka skilli
DevOps i chmura · Automatyzacja

rsync

/rsync

Kopiuje i synchronizuje pliki lokalnie lub przez SSH, wysyłając tylko zmienione fragmenty: kopiowanie na serwer, lustro katalogu, przyrostowe kopie zapasowe, wdrażanie builda i wznawianie transferu.

Repozytorium
skills ↗
Licencja
Apache-2.0
Ostatnia zmiana repozytorium
25.10.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
2
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
1
Przestarzałość

Brak sygnałów. Repozytorium zmienione 25.10.2026, bez odwołań do wycofanych modeli i API.

Licencja

Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.

Co robi i kiedy

Kopiuje i synchronizuje pliki lokalnie lub przez SSH, wysyłając tylko zmienione fragmenty: kopiowanie na serwer, lustro katalogu, przyrostowe kopie zapasowe, wdrażanie builda i wznawianie transferu.

Wyzwalacze z opisu

copy files to a serversync two directoriesmirror a foldermake incremental backups with hard linksdeploy a build to a remote hostresume a big transferexclude node_modules when copying
Oryginalny opis (EN)

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".

Jak działa

  1. Overview
  2. Instructions
  3. Examples
  4. Guidelines
Sekcje z nagłówków SKILL.md, w oryginale · 97 linii, 765 słów
Podgląd SKILL.md
---
name: rsync
description: >-
  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".
license: Apache-2.0
compatibility: "Linux, macOS, BSD; rsync 3.2+ on both ends for the options shown, SSH access for remote paths"
metadata:
  author: terminal-skills
  version: "1.1.0"
  category: devops
  tags: "rsync, sync, backup, deploy, file-transfer"
  repository: https://github.com/RsyncProject/rsync
---

# 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

```bash
rsync -a --info=progress2 ./dist/ deploy@web01.example.net:/var/www/shop/   # local to remote
rsync -a deploy@web01.example.net:/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

```console
$ 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

```bash
rsync -a --delete --exclude='node_modules' --exclude='.git' --exclude='.env' ./build/ deploy@web01.example.net:/var/www/shop/
rsync -a --exclude-from=.rsync-ignore ./app/ /backups/app/
rsync -a --files-from=changed.txt ./app/ deploy@web01.example.net:/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

```bash
rsync -a -e "ssh -p 2222 -i ~/.ssh/deploy_ed25519" ./dist/ deploy@web01.example.net:/var/www/shop/
rsync -a --rsync-path="sudo rsync" ./conf/ ops@db01.example.net:/etc/shop/    # needs passwordless sudo for rsync there
rsync -a --partial --append-verify --info=progress2 big.iso backup@nas01.example.net:/vol/iso/   # resume a big file
rsync -a --bwlimit=5m ./media/ backup@nas01.example.net:/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:

```bash
#!/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"

```bash
npm run build
rsync -a --delete --exclude='/uploads/' --exclude='/.env' -n -i ./dist/ deploy@web01.example.net:/var/www/shop/
rsync -a --delete --exclude='/uploads/' --exclude='/.env' ./dist/ deploy@web01.example.net:/var/www/shop/
ssh deploy@web01.example.net "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` compares file contents instead of size and time: accurate but reads every file on both sides.
- Do not sync live database files; dump first, then sync the dump.
- Do not store the SSH key passphrase or passwords in scripts; use `ssh-agent` or a dedicated deploy key.
- For one-way deployment prefer a new release directory plus a symlink switch if you need atomic cutover; rsync on its own updates files one by one.
Pliki w paczce (2)
  • SKILL.md 6 KB
  • _scores.json 2 KB

Wersje

W bazie nie ma innych skilli o nazwie rsync.

Migawka bazy z 13.11.2026 · wersja paczki ab28ac2e7ed9 (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100model-sync
    Synchronizuje pliki modeli ML między serwerami przez rsync, z kontrolą przepustowości i weryfikacją sum kontrolnych.
  • 90ostiary
    Uruchamia polecenia i przesyła pliki na zdalnych serwerach przez narzędzie ostiary, zamiast bezpośrednio przez ssh, scp czy rsync.
  • 100linux-rsync-sync
    Planuje, podgląda i weryfikuje kopie rsync, lustra, transfery poza siedzibę i kopie z twardymi dowiązaniami, z obsługą SSH, filtrów, usuwania, sum kontrolnych i wznawiania.
  • 100bdb-deploy
    Buduje projekt i wdraża go bezpośrednio na serwer przez rsync po SSH, gdy trzeba wypchnąć build na produkcję bez pełnego potoku CI.
  • 100ssh
    Obsługuje zdalny dostęp przez SSH: połączenia, tunele, klucze i transfer plików, w tym przekierowanie portów oraz scp i rsync.
  • 100sc-sync
    Synchronizuje rsync-iem pliki z gitignore między VPS a lokalnym komputerem przez Tailscale, zawsze najpierw na sucho, a kopiowanie dopiero z flagą --apply.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.