The important part is the working directory, the execstart can be left untouched, here’s the contents of my service
section for reference:
[Service]
Type=notify
ExecStart=/opt/mattermost/bin/mattermost
TimeoutStartSec=3600
Restart=always
RestartSec=10
WorkingDirectory=/opt/mattermost
User=mattermost
Group=mattermost
LimitNOFILE=49152
But please do not change that right now, we need to first merge your data, now let me describe your situation.
Disclaimer: I have not tested any of the commands, they’re provided as-is without warranty out of my head If you encounter error messages, let me know.
I’m also available on the Mattermost community server with the same name if you want to talk about migration errors more quickly.
bin/config only contains the let’s encrypt cache for your recent try, but besides that, it does not contain any relevant information, so my suggestion here is to just delete it.
bin/data contains data back to July 2021 and up to Jan 2023, so this seems to be the recent data directory and we need to keep it (but it should be moved to a different location).
Additionally, I found a third one: bin/data/data which contains data up to 2023-01-13 to further complicate things…
/opt/mattermost/data does not contain any relevant data, but it has another subfolder called “data” (so /opt/mattermost/data/data) which contains data back to 2019-07 and ends in 2021-07 (so something happened in July 2021 which introduced a new directory).
Please note that you are currently not able to access attachments from before 2021-07, because they are not accessible by your Mattermost installation.
When you fix the systemd unit, please also check what the value for the FileSettings.Directory
in your /opt/mattermost/config/config.json
looks like. It needs to be either ./data
(which will work once you change the working directory) or it needs to be the full path, that is /opt/mattermost/data
.
Before you do any changes to the filesystem layout, please create a full backup of the /opt/mattermost
folder so we can revert to it when anything breaks (or create a snapshot of your system, if it’s a virtual machine).
- Stop your Mattermost server
- Fix the systemd unit
- Run
systemctl daemon-reload
to reload it - Delete the superfluous config directory
rm -r /opt/mattermost/bin/config
- Remove the superflous data directory
mv /opt/mattermost/data/data/* /opt/mattermost/data
rmdir /opt/mattermost/data/data
- Merge the data from
bin/data/data
into the new data directoryrsync -au /opt/mattermost/bin/data/data/ /opt/mattermost/data/
- Move this directory out of our way
mv /opt/mattermost/bin/data/data /opt/mattermost/bin-data-data
- Merge the data from
bin/data
into the new data directoryrsync -au /opt/mattermost/bin/data/ /opt/mattermost/data/
- Move this directory out of our way
mv /opt/mattermost/bin/data /opt/mattermost/bin-data
The above mentioned rsync
command copies all data from the existing data directories into another data directory, but skips files that are newer on the destination, so you should end up with a merged data directory that contains all the files back to 2019. You can verify that when you run ls -l /opt/mattermost/data
after step 9, it should contain all folders from 2019 to 2023. If this is the case, then you’re good to go and can start Mattermost again:
- Start Mattermost
Once Mattermost is running, please send another ls -lR /opt/mattermost
so I can see if it updated all the directories correct and please do some testing to see if you’re able to access your attachments (for newer and older posts).