Skip to content

Historical Artifacts

Song Zheng edited this page Jan 13, 2022 · 2 revisions

8/23/2020 - Localhost to Digital Ocean

Due to house move, we need to migrate everything that is hosted locally to remote hosting. All of the big items will have to be moved.

c0d3.com

  • Acquire a new DO server.
  • Install Postgres on new machine
    • Create new user (CREATE USER john WITH PASSWORD '0aoAOUE'; )
    • Create database (createdb c0d3_testing)
  • Postgres should allow remote connections: Modify file in /etc/postgresql/12/main/postgresql.conf.
  • Restart Postgres: service postgresql restart
  • Postgres DB Dump c0d3 data (in old machine) - pg_dump c0d3_prod > ~/aug23-2020-c0d3_prod.sql
  • Xfer dump to new machine: scp aug23-2020-c0d3_prod.sql postgres@new-ip:~/
  • Postgres DB Import c0d3 db into new machine - psql c0d3_testing < aug23-2020-c0d3_prod.sql -U c0d3_admin --password
  • switch databases on vercel
  • Testing - create new account on new c0d3.com and the old c0d3.com website did not reflect the new account, proving that the new c0d3.com is using the new database

chat.c0d3.com

  • Upgrade Mattermost (old server)
  • DB Dump of mattermost chat server
  • Install Mattermost (new server)
  • DB Populate mattermost chat postgres to new db
  • Setup loadbalancer myProxy (old computer) to point to new server
  • Make sure old and new configurations matches
  • Plugin Setup
  • Make sure access tokens (for chatroom updates) work

Other apps

  • Install myProxy into new server.
  • DNS mapping to new server
  • Migrate existing apps to new server

Helpful commands

Postgres

  • Change user password ALTER USER user_name WITH PASSWORD 'new_password';
  • Create database CREATE DATABASE dbname OWNER rolename;

Upgrading Mattermost

We migrated to discord, so mattermost is no longer used

To upgrade the Mattermost server that runs c0d3's chat, follow through these steps.

Most of the instructions here are from the Mattermost upgrading guide, so if something doesn't work first check the official documentation.

  1. SSH into the server and switch to the root user. If you don't have access, ask for help in the engineering channel.
# Replace <user> with your username
ssh <user>@chat.c0d3.com
sudo su
  1. Before doing anything related to Mattermost, make a backup of the PostgreSQL database. First switch to the postgres user and then make a backup using pg_dump.
# From here, you can assume the commands are run as root
su - postgres
pg_dump mattermost > mattermost_db_$(date +'%F-%H-%M').psql
logout # return to root user
  1. Download and extract the new Mattermost server files.
cd /tmp
# Replace X.X.X with the Mattermost version (e.g. 5.27.0)
wget https://releases.mattermost.com/X.X.X/mattermost-X.X.X-linux-amd64.tar.gz
# Extract the files to 'mattermost-upgrade'
tar -xf mattermost*.gz --transform='s,^[^/]\+,\0-upgrade,'
# Change ownership of the new files
chown -hR mattermost:mattermost /tmp/mattermost-upgrade/
  1. Stop the server and make a backup of the current Mattermost server files.
# Stop the server
systemctl stop mattermost
# Backup current server
cp -ra /opt/mattermost/ /opt/mattermost-back-$(date +'%F-%H-%M')/
  1. Copy the new version files to the installation directory.
# Remove all files except special directories from within the current mattermost directory.
find /opt/mattermost/ /opt/mattermost/client/ -mindepth 1 -maxdepth 1 \! \( -type d \( -path /opt/mattermost/client -o -path /opt/mattermost/client/plugins -o -path /opt/mattermost/config -o -path /opt/mattermost/logs -o -path /opt/mattermost/plugins -o -path /opt/mattermost/data \) -prune \) | sort | xargs rm -r
# Copy the new files
cp -an /tmp/mattermost-upgrade/. /opt/mattermost/
  1. Enable Mattermost to bind to lower ports.
setcap cap_net_bind_service=+ep /opt/mattermost/bin/mattermost
  1. Start the service back again to run the server.
systemctl start mattermost
  1. After the upgrade remove the temporary files.
rm -rf /tmp/mattermost-upgrade
rm /tmp/mattermost*.gz