Download Plex Database Via CLI

Im just wondering if there is a CLI version of the Troubleshooting button in plex web “Download Database”. I like to backup my database daily via scripts which currently require shutting plex down before copying the database out from the Plex Media Server folder. I would prefer not to shut plex down so much.

Thanks!

1 Like

Will this do?

That still requires stopping Plex. I was wondering if there was an option without stopping Plex.

No. there is not. The portion of the API which supports it is proprietary

If you stop, make a tar ball of only the database directory, then restart your downtime is minimal.

Ok. Thanks chuck!
I might try to make a webscraper to go manually push the Download Database button.

if you go to Plex Web > settings > troubleshooting > download database

you can mouse over the download database button, and see the URL.

I haven’t tried it, but perhaps a WGET will do what you want?

also, plex does make it’s own backups automatically by default (unless you disabled it at some point).

your script could instead just copy the backup folder files to your intended backup destination.

or just point the plex backup folder to the applicable place.

image

I attempted the wget, it just sits trying to connect to the IP, im assuming as it cant authenticate. Also the file name changes with the time. I do know it makes backups every 3 days, Id just prefer daily. I currently stop plex daily to get these backups, but find it annoying that its necessary to stop it when theres a button that does it already. Ill be the first to admit this is picky.

did you try changing the host to 127.0.0.1 (or whatever your local pms ip is) ?

https://127.0.0.1:28800/diagnostics/databases?X-Plex-Token=yourplextokenhere

also, keep in mind the wget time out may need adjusted if your db is large and/or server is slow.

1 Like

Ive got a domain for it, so it resolves the external IP and attempts to connect to that. I can try the localhost option tho.

I got it to connect but it requires authentication. Any idea how to authenticate via CLI? lmao new way to access plex-web: CLI. Imagine ASCII versions of your media. CHUCK DO IT!

weird that it requires more than the token. perhaps a security measure to prevent tokenized applications from downloading the database directly.

I wonder if you could pull a cookie from an authenticated browser session, then use it with wget to authenticate along with the token.

maybe the 2nd answer @ https://askubuntu.com/questions/161778/how-do-i-use-wget-curl-to-download-from-a-site-i-am-logged-into

I know how to do it.

Telling you is the problem. LOL :rofl:

Just think it through. If you know Plex, you’ll get it

Hahaha you legally handcuffed lout. I understand. Just make sure to laugh at me about it every once in a while. So is there just a command or something that you cant tell or is it secret login information to the core or plex thats required?

It’s a little more secret than “Two all beef patties, special sauce…”
But watch your browser for other things.

end of hint

Haha love you chuck. Lets say I figure it out, as I am now determined to do: Would it be a problem if I shared?

it would be preferred if you dont.

The reason is: You need know how to put the database back.
For those who blindly download, without knowing how to put it back…

Guess who they’re going to ask for help? Any ideas? hmmm :thinking:

Not me!

I make you this deal.

You figure out.

You post the how-to.

I send them to you.

:rofl:

Baller. Got it. If anyone wants this, let me know and Ill personally help you. Dont bother chuck.

ROTFLMAO!

:rofl: