This is a follow-up to my previous blog post Mastodon instance admin deleted all of our DMs after 15 days. After I published that blog post, I was arguing with someone (ignorant) online who engaged in blaming the victim and insisted that I ought to be backing up my Mastodon data weekly to avoid data loss. During that argument, I realized that there may be no way to backup the direct messages (private mentions) you've received from other Mastodon instances, and thus no way to avoid the data loss caused by the content cache retention period of your instance. I decided to put it to the test. Luckily, my new Mastodon account has already received a few DMs from another instance, so I could test immediately.
Here's a screenshot of the /settings/export Data export page on my Mastodon instance. It says, "You can request an archive of your posts and uploaded media. The exported data will be in the ActivityPub format, readable by any compliant software. You can request an archive every 7 days."

As you can see, I requested an archive earlier today. After you request an archive, you receive an email notification that your archive is ready for download. The downloaded file is a .zip archive that when expanded includes, among other files, an outbox.json with the data from all of your Mastodon posts. If you've written a lot of posts, the file size can be megabytes or larger. In my case, since I just started a new Mastodon account, the outbox.json was only 56 KB.
Unfortunately, my theory turned out to be correct: while the outbox.json does have the data from the DMs that I sent, it doesn't have the data from the DMs that I received. I checked all of the other files in the archive, and they didn't have the received DMs either. The conclusion, in other words, is that you cannot backup the DMs you've received from other instances on Mastodon.
One question remains unanswered by my test: does your Mastodon archive include the DMs you've received from other accounts on your own Mastodon instance? I don't know, because I haven't yet received any DMs from mastodon.social, the instance of my new account. Even if I do receive some same-instance DMs after this blog post, I can't request another archive and test again until 7 days have passed. I encourage other Mastodon users to request an archive and test for themselves.