Migrating media files (documents only) to a fresh install and maintaining the same directory structure

I haven’t worked this way myself, but a possible solution would be:

  1. Upload all of the assets via FTP / SSH / … to the webserver.
  2. Import the assets e.g. via Add From Server plugin.

Doing a quick web search, a lot of tutorials (maybe outdated?) still refer to this plugin for this specific task. It’s last update was ~1y ago – but handling of media files shouldn’t have changed that much.

Make sure to test it on a staging/dev site before doing anything on production!

If you have absolute & relative links to the assets, they will continue working. If you reference the attachments by their ID, these will likely not work anymore, as the IDs are going to change.