[PLUG] Rsync again
John Jason Jordan
johnxj at gmx.com
Sat Oct 6 17:28:21 PDT 2018
On Sat, 06 Oct 2018 13:08:21 -0700
Tomas K <tomas.kuchta.lists at gmail.com> dijo:
>Simple if statement in your backup script should take care of it.
>You can do it number of ways - here is one - checking that there is any
>content in the directory before starting rsync (in bash):
># wait 30 seconds for the directory to mount
>filesInDir=$(ls | wc -l)
>if (( $filesInDir > 0 )); then
> echo "INFO: Backing up files to $backupTargetDir"
> rsync ....
> echo "WARNING: No files in $backupTargetDir"
Here is how I finalized it:
# wait 30 seconds for the directory to mount
filesInDir=$(ls | wc -l)
if (( $filesInDir > 0 )); then
echo "INFO: Backing up files to $backupTargetDir"
rsync -rptog --progress --stats --delete
--exclude-from=/media/jjj/Movies/rsync_exclusions /media/jjj/Movies/ /media/jjj/Synology
else echo "WARNING: No files in $backupTargetDir"
I could probably add another if statement to be sure
that /media/JJJ/Movies is mounted, but that's my work directory, so
it's highly unlikely that it would not be mounted.
I tested it and it works fine! Thanks for the help!
More information about the PLUG