Export and Backup Your Data and Files from Slack

We decided to opt-out of the very noisy universe of Slack in favor of native frictionless messaging, note-taking, and sharing tools. So after navigating the Slack Data Export Jungle and finally exporting data as JSON files, we created a handy Python script to download and backup all shared files, so you don’t have to.

Slack was a good companion over the years, but focusing on actual work while subscribed to multiple Slack workspaces was getting difficult.

In addition, the overabundance of messages during the day was no longer acceptable. To get back on focused work and calm down, we set a fixed deadline for closing our Slack workspace and signing out of all customer workspaces. We used Slack for several years and shared a lot of information, knowledge, and files. So naturally, we did not want to lose any of that.

The Slack export feature enables you to export your data depending on your active subscription.

Free and Pro plan:
The zip file will contain your workspace’s message history in JSON format and file links from all public channels.

Business plan:
The zip file will contain your message history in JSON format and file links from all public channels or from all channels and DMs, depending on your export type.

Enterprise plan:
The zip file will contain your organization’s message history in JSON format and file links from all channels and conversations.

You must be on the Business Plan to export all private channels and conversations. We used a Pro plan for our company over the years, so we had to switch to the Business Plan to create a full export of the whole workspace with all vital information. So, we deactivated all unused user accounts and upgraded to a Business plan, allowing us to export all channels and direct messages as JSON files.

After downloading the workspace export, we got all our channels and direct messages as separate folders, including a JSON file for each day a conversation did take place. Each JSON file consists of an array of messages containing all necessary information. In addition, the files array within the message dictionary includes all shared files during the conversations.

Individual conversations are saved as single JSON files for each day

The property url_private contains the secret URL to the file you need to download. After closing the Slack account, Slack will remove all your files from its servers. Therefore, you need to download and store them in a secure location to retain a full backup.

Fortunately, we crafted a simple Python script to do the job automatically. It goes through all channel directories, creates a “files” folder, and stores the downloaded files. Moreover, the file names are kept the same but prefixed with the message’s ID to avoid collisions.

If you are interested in the downloader script, check out our public repo or just copy the Gist below. It requires a Python 3 environment, and you must pass the path to your Slack export folder. A progress bar displays the status of the download. The execution of the script is idempotent, meaning you can execute it multiple times, and it will download only missing files. This behavior enables you also to backup your files regularly.

2 responses to “Export and Backup Your Data and Files from Slack”

  1. Wow thank you for creating this python script and open sourcing it! I just ran it and it downloaded 49 files and then errored out with:

    File “/Users/jw/code/slack-files-download.py”, line 100, in
    process_directories(args.directory, directories, output=args.out)
    File “/Users/jw/code/slack-files-download.py”, line 50, in process_directories
    [process_message(message, output_dir_path, num=index, total=total_dirs) for message in data]
    File “/Users/jw/code/slack-files-download.py”, line 50, in
    [process_message(message, output_dir_path, num=index, total=total_dirs) for message in data]
    File “/Users/jw/code/slack-files-download.py”, line 67, in process_message
    with urlopen(item[‘url_private’]) as remote_file:
    File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py”, line 216, in urlopen
    return opener.open(url, data, timeout)
    File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py”, line 525, in open
    response = meth(req, response)
    File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py”, line 634, in http_response
    response = self.parent.error(
    File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py”, line 557, in error
    result = self._call_chain(*args)
    File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py”, line 496, in _call_chain
    result = func(*args)
    File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py”, line 749, in http_error_302
    return self.parent.open(new, timeout=req.timeout)
    File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py”, line 525, in open
    response = meth(req, response)
    File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py”, line 634, in http_response
    response = self.parent.error(
    File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py”, line 563, in error
    return self._call_chain(*args)
    File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py”, line 496, in _call_chain
    result = func(*args)
    File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py”, line 643, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
    urllib.error.HTTPError: HTTP Error 410: Gone

    Do you know what is wrong?

  2. Hi, I have tried to use this script, but it seems like it cannot go over the login information

    slack-files-download-main % python3 slack-files-download.py ~/Downloads/SlackExport/
    Traceback (most recent call last):—————————] 50.0% …FQGSWPR3M_IMG_20191121_195402.jpg
    File “/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/urllib/request.py”, line 1348, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
    File “/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py”, line 1282, in request
    self._send_request(method, url, body, headers, encode_chunked)
    File “/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py”, line 1328, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
    File “/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py”, line 1277, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
    File “/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py”, line 1037, in _send_output
    self.send(msg)
    File “/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py”, line 975, in send
    self.connect()
    File “/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py”, line 1454, in connect
    self.sock = self._context.wrap_socket(self.sock,
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File “/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/ssl.py”, line 517, in wrap_socket
    return self.sslsocket_class._create(
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File “/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/ssl.py”, line 1075, in _create
    self.do_handshake()
    File “/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/ssl.py”, line 1346, in do_handshake
    self._sslobj.do_handshake()
    ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:992)

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File “/Users/mainuser/Downloads/slack-files-download-main/slack-files-download.py”, line 102, in
    process_directories(args.directory, directories, output=args.out)
    File “/Users/mainuser/Downloads/slack-files-download-main/slack-files-download.py”, line 52, in process_directories
    [process_message(message, output_dir_path, num=index, total=total_dirs) for message in data]
    File “/Users/mainuser/Downloads/slack-files-download-main/slack-files-download.py”, line 52, in
    [process_message(message, output_dir_path, num=index, total=total_dirs) for message in data]
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File “/Users/mainuser/Downloads/slack-files-download-main/slack-files-download.py”, line 69, in process_message
    with urlopen(item[‘url_private’]) as remote_file:
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File “/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/urllib/request.py”, line 216, in urlopen
    return opener.open(url, data, timeout)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File “/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/urllib/request.py”, line 519, in open
    response = self._open(req, data)
    ^^^^^^^^^^^^^^^^^^^^^
    File “/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/urllib/request.py”, line 536, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File “/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/urllib/request.py”, line 496, in _call_chain
    result = func(*args)
    ^^^^^^^^^^^
    File “/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/urllib/request.py”, line 1391, in https_open
    return self.do_open(http.client.HTTPSConnection, req,
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File “/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/urllib/request.py”, line 1351, in do_open
    raise URLError(err)
    urllib.error.URLError:

Leave a Reply

Your email address will not be published. Required fields are marked *