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?

guettli
  • 3,113
  • 14
  • 59
  • 110

1 Answers1

1

You can try do something like that:

rsync -xavi --rsync-path="[[ -d /media/guettli/backup1t ]] && rsync" --delete --delete-excluded \
  --exclude '...' \
  /  /media/guettli/backup1t/
Anaoliy Tk
  • 38
  • 1
  • 6