Dino Geek, try to help you

How to sync only files that have changed since the last sync with RSYNC?


“rsync” is a file synchronization and file transfer program for Unix systems that minimally transfers file changes. It’s widely used for backups and mirrors over local and wider area networks. Below are steps on how to use rsync to synchronize only files that have changed since the last sync.

First, you simply run a normal rsync command, tailored to your specific needs. For example:

```
rsync -a /source/directory/ /destination/directory/
```

The “-a” option is a combination flag. It stands for “archive” and syncs recursively and preserves symbolic links, special and device files, modification times, group, owner, and permissions.

Each rsync transfer updates the timestamp of the files that it modifies on the destination. If nothing has changed in a file, rsync’s quick check algorithm (which is an important part of its efficiency) will detect this and skip the file. Essentially, rsync already operates by only syncing files that have changed since the last sync.

If you want to be even more specific about only transferring differences since your last sync or backup, you could use the “—link-dest” option, which directs rsync to create hard links to a previous backup. It will only transfer the differences between that backup and the current files, saving space.

It’s worth noting that one of the reasons rsync is so powerful and efficient is because it uses a delta-transfer algorithm, which reduces the amount of data sent over the network by sending only the differences between the source files and the existing files in the destination (source: Samba.org’s rsync features).

However, always be careful when performing file operations like this. It’s easy to erase or overwrite data unintentionally. It’s wise to always run rsync first with the “—dry-run” and “—verbose” options to see what will be changed before you let it run for real:

```
rsync —dry-run —verbose -a /source/directory/ /destination/directory/
```

This will give you a list of changes that would be made if you ran the command for real, allowing you to avoid potential mishaps.

In conclusion, rsync is a reliable and recognized way to sync files between directories while focusing only on changes since the last sync. However, its power comes with a responsibility to use it carefully to avoid unintended data loss.

Sources:
- “rsync”. Samba.org, https://rsync.samba.org/
- Savetz, Kevin et al. “Unix in a Nutshell, Fourth Edition”. O’Reilly Media, Inc., 2005.


Simply generate articles to optimize your SEO
Simply generate articles to optimize your SEO





DinoGeek offers simple articles on complex technologies

Would you like to be quoted in this article? It's very simple, contact us at dino@eiki.fr

CSS | NodeJS | DNS | DMARC | MAPI | NNTP | htaccess | PHP | HTTPS | Drupal | WEB3 | LLM | Wordpress | TLD | Domain name | IMAP | TCP | NFT | MariaDB | FTP | Zigbee | NMAP | SNMP | SEO | E-Mail | LXC | HTTP | MangoDB | SFTP | RAG | SSH | HTML | ChatGPT API | OSPF | JavaScript | Docker | OpenVZ | ChatGPT | VPS | ZIMBRA | SPF | UDP | Joomla | IPV6 | BGP | Django | Reactjs | DKIM | VMWare | RSYNC | Python | TFTP | Webdav | FAAS | Apache | IPV4 | LDAP | POP3 | SMTP

| Whispers of love (API) | Déclaration d'Amour |






Legal Notice / General Conditions of Use