Restore mopidy state after hard reset?

Dear Mopidy Community,

Even if in the ideal world this would never happen, every now and then my (Raspberry Pi-based) webserver goes through a hard reset due to some unavoidable electrical issues in the mains outlets. One annoying consequence is that my Mopidy music server loses the playback queue and history due to this, which goes into the core of my music listening habits. And just to mention, this is independent of the restore_state value, which is set to true in my case.

This leads to two questions:

  • Is there a way to restore the Mopidy server’s state after a hard reset? (I.e. some cache-file somewhere I could move/copy someplace else?) More specifically, the playback queue is of the biggest importance.
  • If not, is it possible to dump the playback queue (and/or history) into stdout/file from the CLI? This would allow for making periodic backups of the queue (and/or history), alleviating the problem.

I’m running Mopidy as a service.

Best greetings and good start of the summer!

I don’t recall when we save the state, from what you describe I guess it’s only during good shutdown. Perhaps there’s scope to do that more frequently but I don’t remember how we implemented it. You could look into that if it’s a feature you want to improve yourself.

For your alternative idea, you can easily dump the queue with Mopidy-MPD and mpc playlist command, and then store the output in a file that you can load back in after your bad shutdown. You could setup that dumping to run periodically with a cron job or systemd timer. You can also achieve the same dumping via the built-in HTTP frontend, but it’s simpler with MPD.

Thanks once again @kingosticks!

It does appear to me too, that the state is not saved during regular runtime, but rather only during a proper shutdown. I also agree, that it could be benefical in situations like these to save more frequently.

I would be happy to look into this myself, but unfortunately I have too much family pressure to take extra development work that is too heavy.. As such, I think the workaround of dumping the play queue in to a file, and wrap that into cronjob will be perfectly fine for my purposes. Thanks for confirming that it is indeed possible directly from the CLI. I have a few cronjobs already setup that fire some backup routines, so I think it’ll be straight-forward to modify to accomplish what I need.

Thanks again!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.