I just made some test:
- Backup with userdata on RootFS
- Move userdata to external drive
- Restore backup
- Result: Old /mnt/dietpi_userdata dir is restored, overwriting the symlink which was created when moving userdata. This is actually as it should be, since also fstab entries are reverted which can render symlinks pointing to an invalid path after reboot.
But if userdata is already on an external drive, e.g. /mnt/sdb/dietpi_userdata, it is actually not backed up . The way we add includes/excludes does not include any sub dir of /mnt/ (besides /mnt/dietpi_userdata) and does not follow (or even include) the /mnt/dietpi_userdata symlink into the backup.
Usually this is okay if stuff is on an external drive anyway, but actually the idea that time was to include dietpi_userdata into the backup in every case. There is an inclusion rule for this, but it has no effect since the related subdir (e.g. /mnt/sdb/) is not even entered.
And since the old fstab is recovered, the userdata mount can be missing after reboot, at least if one does not open drive manager before reboot to auto-readd the active mount.
That is actually an issue in case of some programs which have files in userdata and if the current installed version/files in RootFS do not match and are not compatible with the ones in userdata (e.g. MariaDB version and database files in /mnt/dietpi_userdata/mysql). So it would make sense to change the include/exclude rules so that external userdata + symlink is backed up as well.
But then another issue can occur:
If you backup with external userdata and before restoring, move the userdata back to RootFS, then the symlink overrides the current userdata. And since the previous userdata dir is not inside the include list (only the current one), it is not restored.
Can be as well solved by adding the old userdata dir to the include list before restoring. This will be in RootFS then in case the mount does not exist anymore, so e.g. /mnt/sdb/dietpi_userdata but not as a mount. It can be moved again to an external drive from there, but if userdata were very large (much media, downloads and such), the RootFS (SDcard) can easily not have enough free space for restoring.
And generally when recovering userdata:
Actually content in userdata/Music|Video|Pictures|downloads should not be restored, at least not the way that files that are not present in the backup, are removed. In case of some strange/broken system, you want to recover system and programs, which must include removing newly created files, but newly created media files and downloads should be preserved. This makes the include/exclude rules even more complicated when resolving the above issues with changed userdata.
Puuuuh complicated thing…
Actually I believe the best is to compare userdata location from backup with the current one and abort restoring the backup if it does not match. So first user must in case restore the old mount + move userdata back. And then on restore we can ask user if Musik/Video/Pictures/downloads should be restored as well or not. When restoring onto a fresh SDcard, you usually want it, when restoring to repair a broken system, e.g. failed update, bad software install or such, you usually want to keep media as is. The question can be skipped for empty media dir of course.
Additionally we should prompt a hint when moving userdata, that an existing backup should be updated afterwards to have correct userdata location and related fstab entry there as well.
Okay larger topic. At least the current behaviour does never destroy something. Have to sleep about it to hopefully find a more elegant solution, e.g. automatically recovering old userdata (skipping media/downloads) to the new userdata location and preserving/re-adding the related fstab entry…would be nice…