For recursive mirroring common use would be
rsync -a --delete --progress sourceDir destinationDir/
Your example: rsync -a --delete /media/jjj/Movies /media/jjj/Synology/
Good way to see if you want to use --delete might be to count the number of
files to be updated and/or deleted with dry run '-n' and base on the number
decide what to do:
rsync -an --delete --progress sourceDir destinationDir/
This will print all files being deleted and updated.
Your example: rsync -an --delete --progress /media/jjj/Movies
/media/jjj/Synology/
In bash script you could do something like this:
#!/bin/bash
updateMax=100
deleteMax=50
filesToUpdate=$(rsync -an --delete /media/jjj/Movies /media/jjj/Synology/ |
grep -v 'sending incremental file list' | wc -l)
filesToDelete=$(rsync -an --delete /media/jjj/Movies /media/jjj/Synology/ |
grep -v 'sending incremental file list' | grep '^deleting ' | wc -l)
if (( $filesToUpdate < $updateMax )); then
if (( $filesToDelete < $deleteMax )); then
echo "INFO: Files being updated: $filesToUpdate"
rsync -a --delete --progress /media/jjj/Movies /media/jjj/Synology/
else
echo "WARNING: Too many files to delete $filesToDelete ... Updating only"
rsync -a --progress /media/jjj/Movies /media/jjj/Synology/
fi
else
echo "ERROR: Too many files $filesToUpdate changed. Skipping update ...."
fi
exit 1
It you run it manually, you will see the output. If you run it as cron you
could write it to a log or let cron will send you email with the output or ...
I hope it helps, Tomas
On Wed, 2016-07-13 at 11:24 -0700, John Jason Jordan wrote:
> On Tue, 12 Jul 2016 17:10:39 -0700
> John Jason Jordan <[email protected]> dijo:
>
> > And that brings up my immediate problem. Bear in mind that I want the
> > destination to be a mirror of the source, hence my need for the
> > --delete option. Unfortunately, it doesn't seem to be working. Here is
> > my current command:
> >
> > rsync -rptog --delete /media/jjj/Movies/* /media/jjj/Synology
> >
> > The command executes fine, except that the --delete doesn't happen:
>
> I finally discovered the problem. The --delete option doesn't take
> wildcards. But the * was actually unnecessary in the first place. After
> deleting it the --delete option worked.
> _______________________________________________
> PLUG mailing list
> [email protected]
> http://lists.pdxlinux.org/mailman/listinfo/plug
_______________________________________________
PLUG mailing list
[email protected]
http://lists.pdxlinux.org/mailman/listinfo/plug