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
Rsync Help
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Topics in this forum are automatically closed 6 months after creation.
Rsync Help
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Re: Rsync Help
This is what I use to sync to a backup server
rsync -aviuh --progress --delete-after source target
Re: Rsync Help
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.
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.
Did I miss something?
- smurphos
- Level 18
- Posts: 8501
- Joined: Fri Sep 05, 2014 12:18 am
- Location: Irish Brit in Portugal
- Contact:
Re: Rsync Help
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.
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.
Re: Rsync Help
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
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.- smurphos
- Level 18
- Posts: 8501
- Joined: Fri Sep 05, 2014 12:18 am
- Location: Irish Brit in Portugal
- Contact:
Re: Rsync Help
Lose the
I refer to
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. For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.