How to define /etc/fstab entries to support rsync backups to external USB drives

Yes, and no.
As long as the device remains connected it cannot be again accessed (It was “ejected” and the config was removed)
However, if you unplug the usb device and reconnect it the device should once again be seen without a reboot.

The eject command dismounts the device and removes its config from /dev.
If you were to use the umount command then it could still be accessed (though possibly not through discover)

Correct but not what you seem to be asking.
the device itself would be the same under disk2s1/ even if the mount path /run/media/$USER/ is different. Thus what you show as /run/media/rhimbo/disk2s1/home would be identical for each user with only the user name changed in that path. The content of disk2s1/home/ would be the same for everyone.

The earlier suggestion of creating a mount point such as /mnt/backup/ then adding an entry in /etc/fstab to mount that device at that location would be ideal.

Then after mounting that device, simply create a directory with proper ownership for each user in /mnt/backup.

As an example, using your user name, (only after the drive is mounted as suggested) that could be done such as sudo mkdir /mnt/backup/rhimbo and set ownership with sudo chown rhimbo:rhimbo /mnt/backup/rhimbo (Do these steps only once)

Now your backups could be done with rsync -av /home/rhimbo/ /mnt/backup/rhimbo/ (Do this as often as desired)

To avoid filling the backup with the temporary files such as caches that no longer exist it would be useful to use one of the --delete… options with rsync.

The steps to create the directory, set ownership, and perform the backup would be identical for each user and the only changes would be the user names in those commands. Of course the creation of the directory and ownership permissions would be only done once but the backup with rsync could be done as often as desired ( as noted above).

1 Like