Sample Header Ad - 728x90

Run rsync only if target directory exists?

2 votes
2 answers
1922 views
I have a secondary backup drive that is usually stored offsite, but sometimes mounted. I'd like to put something in a crontab that automatically clones my backup drive to the secondary backup if it's mounted. I know that I could do something like: if [ -d $target_dir ]; then rsync -a --delete $src_dir $target_dir; fi but I'm wondering if there's a way to ask rsync the same thing, without resorting to a shell script? Given that it has 6.02*10^23 command line options, you'd think so...
Asked by Scott Deerwester (411 rep)
Nov 2, 2018, 04:47 PM
Last activity: Jul 6, 2025, 07:34 AM