0

I want to rsync my root directory to an external hard disk mounted under /media/guettli/backup1t/.

rsync -xavi --delete --delete-excluded \
  --exclude '...' \
  /  /media/guettli/backup1t/

Something went wrong with the mounting and rsync happily created /media/guettli/backup1t/ in the root directory and rsynced copied files there and not onto the external hard drive.

I would like to avoid this.

I could do it with a shell script which checks that /media/guettli/backup1t/ exists before starting rsync, but I would prefer an option to rsync.

How can I tell rsync to not start the sync, if the destination does not exist?

1

1 Answer 1

1

You can try do something like that:

rsync -xavi --rsync-path="[[ -d /media/guettli/backup1t ]] && rsync" --delete --delete-excluded \
  --exclude '...' \
  /  /media/guettli/backup1t/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .