I have setup rsync to mirror a directory from a source server(a) to a mirror(b). I have gotten it to send new files that are on the source but when I delete a file from the source it doesn't end up deleting it.
Below is what I use to call rsync:
rsync -vhzrplt --stats --delete --rsh='/usr/bin/ssh -q' --exclude="core/" --exclude="cache/" /home/(a)/public_html (b):/home/(b)/public_html/
When I run rsync i get the output below:
stdin: is not a tty
sending incremental file list
public_html/
deleting public_html/test.html
Number of files: 389
Number of files transferred: 0
Total file size: 3.16M bytes
Total transferred file size: 0 bytes
Literal data: 0 bytes
Matched data: 0 bytes
File list size: 9.25K
File list generation time: 0.001 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 9.33K
Total bytes received: 47
sent 9.33K bytes received 47 bytes 1.25K bytes/sec
total size is 3.16M speedup is 336.81
As you can see it shows that it's deleting test.html but it never ends up doing it. Any help is appreciated.
To do this you simply add the --delete option to rsync. Now any files under /target/dir/copy that are not also present under /source/dir/to/copy will be deleted.
By default rsync doesn't delete any files at the destination side. To make rsync delete files at all, you need to use at least one of the delete options. If you don't care when files are being deleted, just use --delete and leave the choice to rsync .
rsync is a useful and efficient synchronization tool for transferring files and directories. rsync works in the archive mode if the -a option is passed. It synchronizes the directories recursively. It also keeps the ownership of users and groups, permissions, symbolic links (symlinks), and timestamps.
rsync(1) -avz. a fast, versatile, remote (and local) file-copying tool. -a, --archive This is equivalent to -rlptgoD. It is a quick way of saying you want recursion and want to preserve almost everything (with -H being a notable omission).
I was able to fix this by using this instead:
rsync -vhzrplt --stats --delete --rsh='/usr/bin/ssh -q' --exclude="core/" --exclude="cache/" /home/(a)/public_html/ (b):/home/(b)/public_html/
Add trailing slashes to paths that are folders.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With