[Magisk] Sass86oh:
Basically without making this any harder than it needs to be I'm going to assume that you know the partitions that are listed in TWRP when you flash a new ROM system data vendor and internal storage there's also cache and Dalvik cache but those aren't really important actually none of it is important except for data.

The data partition is the location of all of your devices information that gets added on by you like when you download applications or when you store your user accounts and things like that. The two locations that were worrying about inside of this partition are the following

/data/data - This contains all of the applications and their information and it is the main folder that fills up as you use your applications you set them up and you add your passwords and things like that. It is erased whenever you factory reset or flash a new ROM. Which is what causes our problems and makes us so mad when we have to set up over and over and over again when we keep flashing ROMs.

/data/media - This location is where the SD card is allocated except it's virtually mounted to the root system but because of the SD cards mount point it means that this folder is not at risk of being wiped out every time you want to flash a new ROM it's persistent it will stay the same it will not be erased you can erased. In fact even if you select the data partition inside of TWRP and you wipe it it will wipe every single folder inside of the date of partition except for this particular folder because of how Android mounts the virtual SD card here and that's where all of your personal data remains so it has to be safe no matter what.

This module does something very clever to solve the problem of constantly having to take backups what it does is it creates the following folder inside the folder above which I explained we don't have to worry about being deleted

so all that happens is we create the adk folder in our /data/media location which gives us the new an more importantly PERMANANT ACROSS ROM CHANGES. Inside of the adk folder is going to be the location of not only the appbkp backup folder but also preferences and things like that but I'm just only talking about the app backup folder here just to not confuse people so hopefully that you can see what I'm getting at and then the same thing applies to the other folders in the magisk module gives you a good rundown of everything 2 but for the sake of trying to be it's not confusing as possible about this...

/data/media/adk/appbkb - and this is how it gets clever and works beautifully what it does now AND the whole reason you need to do it from the beginning is it has to delete /data/data completely which will cause you to lose all of your app data if there's anything inside of there and that's why it's done with a fresh ROM. BECAUSE It Has TO CREATE A SYMLINK THAT sits in the exact location meaning /data and it has to be named data just like the other folder in order to give us the same /data/data directory only instead of being an actual folder that second data one is a symlink which really points back the appbkp folder we created in /data/media/adk

If the original folder that we replaced with a symlink (which is the Android default directory for housing all downloaded apps in their data) isn't deleted we wouldn't be able to name the symlink to match that folder specific folders name and we wouldn't be able to proceed with this in a working manner. What this does is it basically makes the app folder where all of the appdata and everything like that gets store to into a sort of area that just redirects to our permanent folder so every time we download an app and we save its data the Android system will still save it just like it always does accept the file that we have in place now instead of being a folder like it always is is just a relay to our permanent location so every app we download and every date of that is generated for that app is going to be saved in our permanent location and upon reflashing firmware we now have the ability to delete the blank folders on the flat on the fresh Rams and just symlink back to that location and continue doing this for as long as we want basically giving the easiest backup method you could ask for.

A symlink is literally just a file that foints to a specific location of a real folder and is meant to allow the folder that actually contains the data to be anywhere you want it to be in this case an area that safe that we don't have to worry about and be able to link it into an area that it needs to be in order for it to be recognized and used and this case in that area that we do need to worry about it being deleted and by doing it this way we can trick Android into believing the folder still there without having to worry about losing all that data every time we flash a new ROM.

So you said everything up from scratch flash your ROM install this magic module module right after you install magisk after you set up the wrong and it will get everything set for you and then from that point forward anything you download anything that you install any information that's generated will no longer be in that volatile partition that we have to worry about losing because instead the symlinks will already have been made the directory will have been created in the permanent location and anything that gets download it is now funneled into that permanent location and there for when we restore and then we just run the script again and it will restore everything exactly how we want it upon flash new ROMs.

In its simplest form this module is just creating the permanent location and data / media house all of our device configuration and application files in a permanent location that we can then restore with the terminal script upon setting up new ROMs and we can do this with ease I'm telling you just go through and just read and try to look at the layout of the magisk module if you have to open it up and look at the config. Sh file on there I mean whatever will help you understand exactly what it's very just got to set it up that one time and it'll start fondling everything in there itself and then from then on it's just your job to set it up to do the same thing and then initiate the restore of all of the apps that you got in there after setting it up the initial time