Unable to download exported data

Summary
I’m unable to download a full, non-corrupted exported archive of my cloud instance. Using mmctl, the download gets interrupted randomly and there is no way to recover or continue the download.

Steps to reproduce
I followed the official guide to export the data: Mattermost workspace migration — Mattermost documentation

  1. mmctl login
  2. create an export archive
  3. mmctl export download

Expected behavior
The entire archive gets downloaded in one session and, if not, it would be resumed at the next attempt.

Observed behavior

  • There are no error messages, no visible retries or multiple attempts: the server closes the connection while downloading, seemingly at random, and the archive gets truncated.
  • If I try to download the file multiple times, every time I get an archive of a different size.
  • If importing the archive is attempted, the import will fail because the archive is corrupted.
  • I am currently trying to work around this issue via a custom script: I’m calling mmctl export download in an infinite loop, discarding a download if it is smaller than the previously downloaded file and it’s been running for hours.
  • The cloud mattermost server does not include Content-Length in the response header, making impossible to know in advance how large is the file to be downloaded.
  • The mmctl client is unable to resume a broken download.
  • I dived a bit into the code, but this issue seems to be server-side, so there’s not much I can do: mattermost cloud is managed by the mattermost team, so I’m locked in until this issue is fixed or I’m lucky enough that a non-corrupted archive is downloaded.

For how long are you able to download before it gets disconnected? Is it always 30 seconds?

Hello , having the same issue , did your matter gate resolved?

@agnivade I don’t think I ever mentioned 30 seconds: it disconnects randomly after some minutes of downloading.

@Daniel254 sorry for the late reply. I ended up using an high-bandwidth server to pass across this issue, but in general it’s not solved… I created a stupid script to retry the download multiple times and settle when the downloaded file doesn’t change for a few times in a row. That + lots of bandwidth worked out.
Here the script, if you need it:

from subprocess import run
from pathlib import Path

pre = Path("previous.zip")
lat = Path("latest.zip")

# Ensure they exist
run(["touch", str(pre), str(lat)])

count = 0
while count < 5:
    print("Downloading...")
    run(
        [
            "mmctl",
            "export",
            "download",
            "XXXXXXXXXXXXXXXXX_export.zip",
            "latest.zip",
        ]
    )

    pre_size = pre.stat().st_size
    lat_size = lat.stat().st_size

    if pre_size < lat_size:
        count = 0
        lat.rename(pre)
    elif pre_size == lat_size:
        print("Good, but count is still low!")
        count += 1
        lat.unlink()
    else:
        print("Bad download, retrying...")
        lat.unlink()
1 Like

I appreciate,I will check this solution ,I got my workaround using the API to download the exported file , uploaded it to my server via wget , then created the import job then finally the created the upload process which was not cumbersome at all

1 Like

Ah, interesting! I couldn’t find the API. I’ll take a better look for the future then.

1 Like

Check here
https://api.mattermost.com/ for full documentation
and here
Mattermost API Reference for export documentation