### Configure, Build, and Install Rsync from Source Source: https://github.com/rsyncproject/rsync/blob/master/INSTALL.md Standard steps to configure, build, and install rsync from its source code. ```bash ./configure make sudo make install ``` -------------------------------- ### Rsync Merge File Examples Source: https://github.com/rsyncproject/rsync/blob/master/rsync.1.md Examples demonstrating how to specify merge and dir-merge filter rules in rsync. ```bash merge /etc/rsync/default.rules ``` ```bash . /etc/rsync/default.rules ``` ```bash dir-merge .per-dir-filter ``` ```bash dir-merge,n- .non-inherited-per-dir-excludes ``` ```bash :n- .non-inherited-per-dir-excludes ``` -------------------------------- ### Example of using --compress-choice and --compress-level Source: https://github.com/rsyncproject/rsync/blob/master/rsync.1.md This example demonstrates how to explicitly set the compression algorithm to zstd and the compression level to 22 for a transfer. It's useful when you want to ensure a specific compression method and level are used, especially when the remote rsync version might not negotiate it automatically. ```bash rsync -aiv --zc=zstd --zl=22 host:src/ dest/ ``` -------------------------------- ### Rsync Filter File Example Source: https://github.com/rsyncproject/rsync/blob/master/rsync.1.md An example filter file configuration demonstrating global merge and per-directory merge rules. ```bash merge /home/user/.global-filter - *.gz dir-merge .rules + *.[ch] - *.o - foo* ``` -------------------------------- ### Display Rsync Help Source: https://github.com/rsyncproject/rsync/blob/master/README.md To get a complete list of supported options, use the --help flag. ```bash rsync --help ``` -------------------------------- ### Rsync Debugging Examples Source: https://github.com/rsyncproject/rsync/blob/master/rsync.1.md Examples demonstrating the use of the --debug option for controlling the level of debug output. Use --debug=help to see available flags. ```bash rsync -avvv --debug=none src/ dest/ ``` ```bash rsync -avA --del --debug=del2,acl src/ dest/ ``` ```bash rsync -aiv {-M,}--debug=del2 src/ dest/ ``` -------------------------------- ### Install Rsync Dependencies on Cygwin Source: https://github.com/rsyncproject/rsync/blob/master/INSTALL.md Installs necessary development packages for rsync on Cygwin using setup-x86_64. ```bash setup-x86_64 --quiet-mode -P make,gawk,autoconf,automake,gcc-core,python38,python38-pip setup-x86_64 --quiet-mode -P attr,libattr-devel setup-x86_64 --quiet-mode -P libzstd-devel setup-x86_64 --quiet-mode -P liblz4-devel setup-x86_64 --quiet-mode -P libssl-devel ``` -------------------------------- ### Install Rsync on Ubuntu via PPA Source: https://github.com/rsyncproject/rsync/blob/master/rsync-web/download.html Use this command to add the rsync project's PPA and install the latest stable release on Ubuntu. ```bash sudo add-apt-repository ppa:rsyncproject/rsync sudo apt update && sudo apt install rsync ``` -------------------------------- ### Rsync Per-Directory Filter Scan Example Source: https://github.com/rsyncproject/rsync/blob/master/rsync.1.md Example of using a filter rule to scan for a per-directory filter file starting from the root directory. ```bash --filter=': /.rsync-filter' ``` -------------------------------- ### Install Rsync Dependencies on Fedora 33 Source: https://github.com/rsyncproject/rsync/blob/master/INSTALL.md Installs necessary development libraries for rsync on Fedora 33 using dnf. ```bash sudo dnf -y install acl libacl-devel sudo dnf -y install attr libattr-devel sudo dnf -y install xxhash-devel sudo dnf -y install libzstd-devel sudo dnf -y install lz4-devel sudo dnf -y install openssl-devel ``` -------------------------------- ### Install Rsync Dependencies on FreeBSD Source: https://github.com/rsyncproject/rsync/blob/master/INSTALL.md Installs required packages for rsync on FreeBSD using pkg. ```bash sudo pkg install -y autotools python3 py37-CommonMark sudo pkg install -y xxhash sudo pkg install -y zstd sudo pkg install -y liblz4 ``` -------------------------------- ### rsyncd.conf &include directive example Source: https://github.com/rsyncproject/rsync/blob/master/rsyncd.conf.5.md Demonstrates how the &include directive processes files in a directory alphabetically. This is equivalent to including each .conf file individually. ```rsyncd.conf &include /path/rsyncd.d ``` -------------------------------- ### Prepare Source from Git Repository Source: https://github.com/rsyncproject/rsync/blob/master/rsync-web/download.html Run this command to fetch generated files if you are compiling rsync from the git repository and encounter issues with setup files. ```bash ./prepare-source fetchgen ``` -------------------------------- ### Install Python Commonmark Library Source: https://github.com/rsyncproject/rsync/blob/master/INSTALL.md If the OS does not provide a python3-cmarkgfm or python3-commonmark package, this command installs the commonmark Python library for the build user, which is needed to generate manpages. ```bash python3 -mpip install --user commonmark ``` -------------------------------- ### Install Rsync Dependencies on Debian/Ubuntu Source: https://github.com/rsyncproject/rsync/blob/master/INSTALL.md Installs necessary development libraries and tools for rsync on Debian and Ubuntu systems using apt. ```bash sudo apt install -y gcc g++ gawk autoconf automake python3-cmarkgfm sudo apt install -y acl libacl1-dev sudo apt install -y attr libattr1-dev sudo apt install -y libxxhash-dev sudo apt install -y libzstd-dev sudo apt install -y liblz4-dev sudo apt install -y libssl-dev ``` -------------------------------- ### Example of --usermap and --groupmap Usage Source: https://github.com/rsyncproject/rsync/blob/master/rsync.1.md Illustrates mapping users and groups between sender and receiver. It shows mapping specific users/IDs and using a wildcard for others. ```bash --usermap=0-99:nobody,wayne:admin,*:normal --groupmap=usr:1,1:usr ``` -------------------------------- ### rsyncd.conf &merge and &include example Source: https://github.com/rsyncproject/rsync/blob/master/rsyncd.conf.5.md A common configuration for /etc/rsyncd.conf that merges global settings from .inc files and then includes module definitions from .conf files. ```rsyncd.conf port = 873 log file = /var/log/rsync.log pid file = /var/lock/rsync.lock &merge /etc/rsyncd.d &include /etc/rsyncd.d ``` -------------------------------- ### Example of --skip-compress Usage Source: https://github.com/rsyncproject/rsync/blob/master/rsync.1.md Demonstrates how to specify a list of file suffixes to exclude from compression. The list is a slash-separated string of suffixes without leading dots. ```bash --skip-compress=gz/jpg/mp[34]/7z/bz2 ``` -------------------------------- ### Sophisticated rsyncd.conf with Multiple Modules Source: https://github.com/rsyncproject/rsync/blob/master/rsyncd.conf.5.md A comprehensive rsyncd.conf example demonstrating global settings and multiple module definitions for different services like FTP, Samba, and CVS. ```rsyncd.conf uid = nobody gid = nobody use chroot = yes max connections = 4 syslog facility = local5 pid file = /var/run/rsyncd.pid [ftp] path = /var/ftp/./pub comment = whole ftp area (approx 6.1 GB) [sambaftp] path = /var/ftp/./pub/samba comment = Samba ftp area (approx 300 MB) [rsyncftp] path = /var/ftp/./pub/rsync comment = rsync ftp area (approx 6 MB) [sambawww] path = /public_html/samba comment = Samba WWW pages (approx 240 MB) [cvs] path = /data/cvs comment = CVS repository (requires authentication) auth users = tridge, susan secrets file = /etc/rsyncd.secrets ``` -------------------------------- ### Rsync Size Only Example Source: https://github.com/rsyncproject/rsync/blob/master/rsync.1.md Illustrates the --size-only option, which modifies the quick check to only consider file size differences for determining if a file needs transfer. ```bash rsync --size-only src/ dest/ ``` -------------------------------- ### Rsync Filter Rule Example for Deletion Source: https://github.com/rsyncproject/rsync/blob/master/rsync.1.md This example demonstrates using filter rules with the --del option to exclude specific files or directories from deletion on the receiving side, while also hiding them from the initial transfer. ```bash rsync -ai --del -f'- *.o' -f'- cmd' src host:/dest/ ``` -------------------------------- ### Basic Rsync with Filter Rules Source: https://github.com/rsyncproject/rsync/blob/master/rsync.1.md Demonstrates basic rsync commands using the --filter option to specify a filter file. The first two examples show scanning for .rsync-filter in parent directories, while the last avoids this parent scan. ```bash rsync -avF /src/path/ /dest/dir ``` ```bash rsync -av --filter=': ../../.rsync-filter' /src/path/ /dest/dir ``` ```bash rsync -av --filter=': .rsync-filter' /src/path/ /dest/dir ``` -------------------------------- ### Write Batch File and Generate Script Source: https://github.com/rsyncproject/rsync/blob/master/rsync.1.md This example demonstrates how to create a batch file and an associated shell script for updating a remote destination directory. The batch file stores update information, and the script provides a convenient way to apply these updates to another destination. ```bash $ rsync --write-batch=foo -a host:/source/dir/ /adest/dir/ $ scp foo* remote: $ ssh remote ./foo.sh /bdest/dir/ ``` -------------------------------- ### Rsync Quiet Mode Example Source: https://github.com/rsyncproject/rsync/blob/master/rsync.1.md Demonstrates the use of the --quiet option to reduce the amount of information displayed during a transfer, useful for cron jobs. ```bash rsync -q src/ dest/ ``` -------------------------------- ### Transfer Specific File with -R option Source: https://github.com/rsyncproject/rsync/blob/master/rsync.1.md Achieves a similar result to the previous example but uses the -R (relative path) option for transferring a specific file. ```bash rsync -aiR x/y/file.txt host:/tmp/ ``` -------------------------------- ### Accept All Delete Options Except '--delete-after' Source: https://github.com/rsyncproject/rsync/blob/master/rsyncd.conf.5.md Accept all delete options by first refusing everything and then negating 'delete' and 'delete-during'. This example specifically allows all delete options except '--delete-after'. ```rsyncd.conf refuse options = * !a !delete !delete-during ``` -------------------------------- ### Run Rsync as a Daemon Source: https://github.com/rsyncproject/rsync/blob/master/rsync.1.md Starts rsync in daemon mode, allowing it to accept incoming connections. ```bash --daemon ``` -------------------------------- ### Example Usage of shifttime.pl Source: https://github.com/rsyncproject/rsync/blob/master/rsync-web/daylight-savings.html This command demonstrates how to use the shifttime.pl script to find files not newer than a reference file and shift their modification times by 3600 seconds (1 hour). ```bash find . -type f ! -newer /tmp/cmpfile | shifttime.pl 3600 ``` -------------------------------- ### Example of Mapping Empty Names Source: https://github.com/rsyncproject/rsync/blob/master/rsync.1.md Shows how to map IDs that do not have a name on the sending side to a specific name on the receiving side, using an empty FROM value or a wildcard. ```bash --usermap=:nobody --groupmap=*:nobody ``` -------------------------------- ### Rsync Stderr Control Examples Source: https://github.com/rsyncproject/rsync/blob/master/rsync.1.md Illustrates how to control stderr output using the --stderr option. This option can be set to 'errors', 'all', or 'client'. ```bash rsync --stderr=errors src/ dest/ ``` ```bash rsync --stderr=all src/ dest/ ``` ```bash rsync --stderr=client src/ dest/ ``` -------------------------------- ### Setting Daemon Configuration Parameters via Command Line Source: https://github.com/rsyncproject/rsync/blob/master/rsync.1.md Allows overriding or setting daemon configuration parameters directly when starting the daemon, equivalent to adding them to the global settings in rsyncd.conf. ```bash rsync --daemon -M pidfile=/path/rsync.pid ``` -------------------------------- ### Rsync: Relative Path Example Source: https://github.com/rsyncproject/rsync/blob/master/rsync.1.md Demonstrates the use of the --relative option to preserve the full path of transferred files on the remote machine. Useful for transferring multiple directories with their structure intact. ```bash rsync -av /foo/bar/baz.c remote:/tmp/ ``` ```bash rsync -avR /foo/bar/baz.c remote:/tmp/ ``` -------------------------------- ### Rsync Ignore Times Example Source: https://github.com/rsyncproject/rsync/blob/master/rsync.1.md Shows how to use the --ignore-times option to disable the quick check based on file size and modification time, forcing all files to be updated. ```bash rsync -I src/ dest/ ``` -------------------------------- ### Using Remote Shell Commands for File Lists Source: https://github.com/rsyncproject/rsync/blob/master/rsync-web/examples.html This example demonstrates how to use a remote shell command to generate a file list for rsync. The shell command is expanded by the remote shell before rsync is invoked. ```bash rsync -avR remote:'`find /home -name "*.{c,h}"`' /tmp/ ``` -------------------------------- ### Read Batch File from Standard Input Source: https://github.com/rsyncproject/rsync/blob/master/rsync.1.md This example shows how to apply a batch update to a remote destination by piping the batch file content through standard input. This method avoids the need to copy the batch file to the remote machine first. ```bash $ rsync --write-batch=foo -a /source/dir/ /adest/dir/ $ ssh remote rsync --read-batch=- -a /bdest/dir/