Created
August 13, 2021 00:14
-
-
Save icelander/09a95e74ef366ca55efb13f49522c4ae to your computer and use it in GitHub Desktop.
Automates the process of resuming mmctl export downloads
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# mmctl-export-downloader.sh | |
## ABOUT | |
# | |
# This script automates the process of downloading a very large Mattermost bulk | |
# exports using mmctl. | |
# | |
## USAGE | |
# | |
# 1. Install and configure mmctl and make sure it's in your $PATH | |
# 2. Use mmctl to generate an export by running this command: mmctl export | |
# create --attachments | |
# 3. Verify that the export job has completed by running mmctl export job list | |
# until the export changes from pending to success. | |
# 4. Find the export filename you want to download , e.g. | |
# fe7j619ysjbk8qkxwu8jyybohr_export.zip by running: mmctl export list | |
# 5. Run this script and pass the filename, e.g.: ./mmctl-export-downloader.sh | |
# fe7j619ysjbk8qkxwu8jyybohr_export.zip | |
# 6. Wait for the the script to finish. If you see repeated errors press Ctrl+C | |
# to exit the script | |
export_filename=$1 | |
if [[ ! -f $export_filename ]]; then | |
# If | |
if mmctl export download $export_filename; then | |
echo "mmctl export file downloaded!" | |
exit 0 | |
else | |
echo "Download interrupted. Resuming..." | |
while ! mmctl export download $export_filename --resume; do | |
echo "Download interrupted. Resuming..." | |
done | |
echo "mmctl export file downloaded!" | |
exit 0 | |
fi | |
else | |
echo "File exists, resuming download..." | |
while ! mmctl export download $export_filename --resume; do | |
echo "Download interrupted. Resuming..." | |
done | |
echo "mmctl export file downloaded!" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment