Page 1 of 1

Rsync Help

Posted: Sun Oct 28, 2018 8:18 am
by OhioYJ
I use the following the command in Windows to make to drives identical, it deletes any extra files / directories, etc from the backup drive.

robocopy source target /E /PURGE

I'm really not in Windows much other than for Steam, so I'd like to recreate this script in Linux. I just need the files on the second drive to end up identical. (It will actually end up being many other drives)

rsync -r -p -t --executability --delete source target

Re: Rsync Help

Posted: Sun Oct 28, 2018 8:42 am
by WharfRat
This is what I use to sync to a backup server rsync -aviuh --progress --delete-after source target

Re: Rsync Help

Posted: Sun Oct 28, 2018 9:29 am
by OhioYJ
WharfRat wrote:
Sun Oct 28, 2018 8:42 am
This is what I use to sync to a backup server rsync -aviuh --progress --delete-after source target
Thanks for your quick I reply. I tried this. Unfortunately it doesn't seem to work. I threw some random files in test folders on the desktop, some different ones, including directories in one, plus a same file and then made changes to one.

Image

After running the command, one folder still has 108 items - 3.5 GB, the other 4 items - 369 kB. I also noted that the terminal says 94 bytes received? Just to make sure I do want this to be only in one direction, the source drive should never be contaminated by the target drive.

Image

Did I miss something?

Re: Rsync Help

Posted: Sun Oct 28, 2018 9:46 am
by smurphos
You need another forwardslash at the end of both your source and destination paths. I think you'll find you've effectively copied test into test2 with your command as written.

Re: Rsync Help

Posted: Sun Oct 28, 2018 9:59 am
by OhioYJ
smurphos wrote:
Sun Oct 28, 2018 9:46 am
You need another forwardslash at the end of both your source and destination paths. I think you'll find you've effectively copied test into test2 with your command as written.
Doh! Well that fixed almost everything. Now the only problem is I made changes to one file in the target destination (so it is technically newer) but I would still like it to be overwritten, with the one from the source. The modified file in the target did not get overwritten.

Re: Rsync Help

Posted: Sun Oct 28, 2018 10:03 am
by WharfRat
smurphos wrote:
Sun Oct 28, 2018 9:46 am
You need another forwardslash at the end of both your source and destination paths. I think you'll find you've effectively copied test into test2 with your command as written.
Yes, the source trailing slash avoids creating an additional directory level at the destination.

So use rsync -aviuh --progress --delete-after source/ target

To test what will be done you can add 'n' rsync -naviuh --progress --delete-after source/ target which will not actually sync -just show what will be done.

Re: Rsync Help

Posted: Sun Oct 28, 2018 10:12 am
by smurphos
Lose the u parameter if you want to delete or overide newer files on the target.

I refer to rsync --help a lot. Like I did just now. :wink: