Search code examples
ruby-on-railsrails-activestorageruby-on-rails-5.2

How to move Active Storage data from one machine to another


Because reasons we are trying to move a system from one machine to another one. It has several files in the storage directory. I rsynced it (using -a) to a local environment to see if everything works, but turns out not all the files are available, some of them raise an exception:

Errno::ENOENT (No such file or directory @ rb_file_s_mtime - /path/to/project/storage/as/df/asdfasdfasdfasdfasdf):

Of course I checked the routes and they exists. I've been reading a bit about how Active Storage works and I maybe the URLs are getting invalidated for some reason, but why some files work? 🧐 Why the exception mentions mtime? And more importantly, how can I do the migration smoothly?

Thanks in advance


Solution

  • So the problem is actually the filesystems + Active Record names 😰 You can consider this a corner case: My local machine runs macOS, while the server runs Linux, so if I had folders Vf and VF on Linux, on macOS they become one (whichever is downloaded firs). Active Storage relies on case-sensitive filenames, and that's why some of the files work fine, but others are not found