@nazokiyoubinbou mounting with the sync option can have a pretty big impact on performance though, and probably won't achieve much that unmounting (which will wait for the filesystem to sync) doesn't already do, just something to keep in mind if it's behaving abnormally slow.
The other thing to consider here is that the disk itself may have an unwritten cache. I've done something like this previously and had to use the sg_sync command before powering the disk off, i was seeing data loss otherwise, even with a filesystem sync/unmount beforehand. (This might be specific to the type of disk, and blockdev --flushbufs might achieve the same thing but more generally, maybe?)
As to the latter point of getting the name of the disk automatically... if your version of lsblk supports --filter you could do something like lsblk -dno NAME --filter 'ID == "blah"' and use lsblk -o +ID to find the id of your disk (then substitute it for "blah")