Score:0

Help understanding rsync command

tg flag

Can someone help me understand the following rsync command, totally new to using rsync.

rsync -av --progress --delete  /exampledir/ root@192.168.0.100:/dir1/dir2/dir3/exampledir/

This command is in a crontab on a different machine, I am assuming that it is deleting the exampledir directory and/or its contents on the 192.168.0.100 machine?

Score:3
mz flag

First of all, if you'd like more info about rsync, you can type rsync --help on your terminal.

-av is using -a flag for archive mode, synchronizes the directories recursively. Keeping the ownership of users and groups, permissions, symlinks and timestamps. Pretty much a collection of the -rlptgoD options. -v is for verbose, which will show you extra information during the process.

--progress will tell you how the process is going, pretty straight forward.

--delete means that every file that is deleted on source, will also be deleted on destination. So if you delete "test.txt" on source, it will also delete it on destination if exists. It is useful if you want mirroring on both sides. TL;DR if it does not exist on source, it will not exist on destination.

The rest of the command is for source and destination, using SSH to connect to root at 192.168.0.100. If you want to automate this you can look for doing backups using tar, find and rsync, all of that on a script called by a cronjob, but using a key pair (ssh-keygen) is mandatory for unattended log in.

Martin Thornton avatar
cn flag
Rather than the terse summary of `rsync --help` I would suggest reading the manual `man rsync`. Not least because you are also making wrong assumptions about what `-a/--archive` means.
Alejandro avatar
mz flag
Yes, I edited my answer so it is correct now, thanks.
Score:0
in flag

Basically, rsync synchronizes the content of two directories, possibly located on different machines. The first directory is the source, the second one, the destination. This means, files are copied to the destination if they are newer or do not exist. Otherwise, nothing happens. The flag --delete in addition, deletes the files that are only in the destination. This ensures to get complete synchronization between the directories.

A good starting point for this is the manual that you can see via man rsync, where you will find the complete description of options (not always easy to understand).

Alejandro avatar
mz flag
Note that rsync is not just for synchronizing content between source and destination, but for transfering files locally or remotely, achieving mirroring (synchronization) is an option.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.