
What rsync is
Rsync stands for remote sync. It is a tool that copies files or directories between remote or local locations using various options.
Option list
- -v: increases verbosity so the copy process is shown in more detail.
- -z: enables compress, so files are compressed while they are copied.
- -h: prints the copy results in a human-readable form.
- -a (same as -rlptgoD): archive mode, equivalent to applying the -rlptgoD options. Those options are described below, and this option copies attributes such as symlinks, permissions, and timestamps as they are.
- -r: used when copying directories.
- -l: copies a symlink as a symlink.
- -p: preserves the permissions of files and directories.
- -t: preserves the modification time.
- -g: preserves the group attribute.
- -o: preserves the owner attribute.
- -e: specifies the shell to use on the remote side.
- -D (same as --devices --specials): the same as the --devices and --specials options.
- --devices: requires root, and copies and creates device-related files.
- --specials: also copies special files such as named sockets or FIFOs.
- -P (same as --partial --progress): the same as the --partial and --progress options.
- --partial: by default, if a transfer is interrupted, rsync deletes the file it was transferring. With this option, the partial file is kept and the transfer can resume from that point, which can make it faster.
- --progress: shows progress during the transfer.
How to use it
You can use rsync with options in local or remote environments.
rsync [option] [원본] [복사본]The rsync usage I use most often is the following.
rsync -r --backup --suffix=`date +'.%F_%H%H%S_UTC'` /원본 / 복사본The --backup option backs up the original file when it has been modified and then syncs the new file, and --suffix lets you specify the form in which the older version is saved.
Using the command above as an example, when you rsync test.sh and there are changes, the existing file is saved as test.sh.2023-01-01_100001_UTC and test.sh is newly synced.
Comments 0
A nickname and a password are required. The same password edits or deletes the comment later. Comments appear after a review.