User Tools

Site Tools


servers:games:cmangos_classic

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
servers:games:cmangos_classic [2023/06/27 17:28] Sean Rhoneservers:games:cmangos_classic [2024/03/12 10:54] (current) – removed Sean Rhone
Line 1: Line 1:
-====== Information ====== 
- 
-  * CMaNGOS ((https://cmangos.net/)) 
-  * mangos-classic ((https://github.com/cmangos/mangos-classic)) 
-  * [[Information:Realm of Espionage]] 
-  * wow.realmofespionage.xyz ((WoW ''realmlist.wtf'')) 
- 
-===== Prerequisites ===== 
- 
-  * [[distros:fedora_server|Fedora Server]] 
-  * [[servers:mariadb|MariaDB]] 
-  * [[games:wine:world_of_warcraft_1.12.x|World of Warcraft (1.12.x)]] ((required for content extraction)) 
- 
-===== Notes ===== 
- 
-  * :!: 2023/06/27: This is copy/pasted from TC 3.3.5 notes and is a large TODO 
-  * [[https://wowdl.net/download/1.12.1-win-us|WoWDL 1.12.1 enUS client]] 
- 
-====== Create Group and User ====== 
- 
-**** 
- 
-  sudo groupadd 'cmangos' && sudo useradd -c 'CMaNGOS system account' -d '/var/lib/cmangos' -g 'cmangos' -m -r 'cmangos' 
- 
-====== Dependencies ====== 
- 
-===== Packages ===== 
- 
-  * https://github.com/cmangos/issues/wiki/Installation-Instructions#fedora-32 
- 
-  sudo dnf install git make cmake gcc patch autoconf mariadb-server mariadb-devel libtool zfstream gcc-c++ subversion boost-devel boost-static bzip2-devel 
- 
-====== Firewall ====== 
- 
-  * 3724/tcp is realmd and needs forwarded from the router also for WAN 
-  * 8085/tcp is mangosd and needs forwarded from the router also for WAN 
- 
-  sudo firewall-cmd --add-port='3724'/'tcp' --permanent && sudo firewall-cmd --reload 
- 
-  sudo firewall-cmd --add-port='8085'/'tcp' --permanent && sudo firewall-cmd --reload 
- 
-====== Download Sources ====== 
- 
-  sudo su 'cmangos' -s '/usr/bin/bash' 
- 
-  cd ~ && mkdir -p ~/'Projects' && rm -Rf ~/'Projects/cmangos-classic/src' && git clone --branch 'master' --depth '1' --recurse-submodules 'https://github.com/cmangos/mangos-classic.git' ~/'Projects/cmangos-classic/src' && sync 
- 
-  cd ~ && mkdir -p ~/'Projects' && rm -Rf ~/'Projects/cmangos-classic-db/src' && git clone --branch 'master' --depth '1' --recurse-submodules 'https://github.com/cmangos/classic-db.git' ~/'Projects/cmangos-classic-db/src' && sync 
- 
-  exit 
- 
-====== Databases ====== 
- 
-===== Initial ===== 
- 
-  * This creates the ''authserver'', ''characters'', and ''worldserver'' databases 
- 
-  sudo mysql 
- 
-  CREATE DATABASE authserver; 
- 
-  GRANT ALL PRIVILEGES ON authserver.* to 'authserver'@'localhost' IDENTIFIED BY 'x'; 
- 
-  CREATE DATABASE characters; 
- 
-  GRANT ALL PRIVILEGES ON characters.* to 'characters'@'localhost' IDENTIFIED BY 'x'; 
- 
-  CREATE DATABASE worldserver; 
- 
-  GRANT ALL PRIVILEGES ON worldserver.* to 'worldserver'@'localhost' IDENTIFIED BY 'x'; 
- 
-  FLUSH PRIVILEGES; 
- 
-  EXIT 
- 
-====== Compile ====== 
- 
-  * [[https://github.com/cmangos/mangos-classic/blob/master/cmake/options.cmake|CMake Options]] 
- 
-  sudo su 'cmangos' -s '/usr/bin/bash' 
- 
-  rm -Rf ~/'Projects/cmangos-classic/build' ~/'Projects/cmangos-classic/run' && mkdir -p ~/'Projects/cmangos-classic/build' ~/'Projects/cmangos-classic/run' && cd ~/'Projects/cmangos-classic/build' && cmake ~/'Projects/cmangos-classic/src' -DCMAKE_INSTALL_PREFIX=~/'Projects/cmangos-classic/run' -DBUILD_PLAYERBOT='ON' -DBUILD_EXTRACTORS='ON' && sync && make --jobs=$(nproc) install && sync 
- 
-  exit 
- 
-====== Extractors ====== 
- 
-  * Copies compiled extractors to ''/tmp/cmangos-extractors'' 
- 
-  rm -Rf '/tmp/cmangos-extractors' && mkdir -p '/tmp/cmangos-extractors' && sudo cp -r '/var/lib/cmangos/Projects/cmangos-classic/run/bin/tools' '/tmp/cmangos-extractors' && sudo chown -R $USER:$USER '/tmp/cmangos-extractors' && sync 
- 
-====== Content ====== 
- 
-===== Transfer Extractors to Client ===== 
- 
-  * :!: Run on the machine doing the content extraction 
-  * See [[games:wine:world_of_warcraft_1.12.x|WoW 1.12.x]] installation notes 
- 
-  mkdir -p '/tmp/cmangos-extractors' && scp espionage724@192.168.1.152:'/tmp/cmangos-extractors/tools/'* '/tmp/cmangos-extractors' && sudo chmod -R +x '/tmp/cmangos-extractors' && mv '/tmp/cmangos-extractors/'* ~/'.wine/World of Warcraft 1.12.x/drive_c/Program Files/World of Warcraft' && sync 
- 
-===== Dependencies ===== 
- 
-  * :!: Run on the machine doing the content extraction 
- 
-  sudo dnf install 'boost' 
- 
-===== Extract and Generate Content ===== 
- 
-==== DBCs, Maps, and Cameras ==== 
- 
-  * :!: Run on the machine doing the content extraction 
-  * 20230627: Takes less than a minute with an i5-8400H 
- 
-  cd ~/'.wine/World of Warcraft 1.12.x/drive_c/Program Files/World of Warcraft' && ~/'.wine/World of Warcraft 1.12.x/drive_c/Program Files/World of Warcraft/ad' -f '0' && sync 
- 
-==== VMaps ==== 
- 
-=== Extract === 
- 
-  * :!: Run on the machine doing the content extraction 
-  * 20230627: Takes about a minute with an i5-8400H 
- 
-  cd ~/'.wine/World of Warcraft 1.12.x/drive_c/Program Files/World of Warcraft' && ~/'.wine/World of Warcraft 1.12.x/drive_c/Program Files/World of Warcraft/vmap_extractor' -l && sync 
- 
-=== Assemble === 
- 
-  * :!: Run on the machine doing the content extraction 
-  * 20230627: Takes less than a minute with an i5-8400H 
- 
-  cd ~/'.wine/World of Warcraft 1.12.x/drive_c/Program Files/World of Warcraft' && mkdir -p ~/'.wine/World of Warcraft 1.12.x/drive_c/Program Files/World of Warcraft/vmaps' && ~/'.wine/World of Warcraft 1.12.x/drive_c/Program Files/World of Warcraft/vmap_assembler' ~/'.wine/World of Warcraft 1.12.x/drive_c/Program Files/World of Warcraft/Buildings' ~/'.wine/World of Warcraft 1.12.x/drive_c/Program Files/World of Warcraft/vmaps' && sync 
- 
-==== MMaps ==== 
- 
-  * :!: Run on the machine doing the content extraction 
-  * 20230627: Takes about 25 minutes with an i5-8400H 
- 
-  cd ~/'.wine/World of Warcraft 1.12.x/drive_c/Program Files/World of Warcraft' && mkdir -p ~/'.wine/World of Warcraft 1.12.x/drive_c/Program Files/World of Warcraft/mmaps' && ~/'.wine/World of Warcraft 1.12.x/drive_c/Program Files/World of Warcraft/MoveMapGen' --offMeshInput ~/'.wine/World of Warcraft 1.12.x/drive_c/Program Files/World of Warcraft/offmesh.txt' --threads '8' --workdir ~/'.wine/World of Warcraft 1.12.x/drive_c/Program Files/World of Warcraft' --buildGameObjects && sync 
- 
-===== Transfer Content to Server ===== 
- 
-  * Should be around 3.6GB 
-  * :!: Run on the machine that did the content extraction 
- 
-  cd ~/'.wine/World of Warcraft 1.12.x/drive_c/Program Files/World of Warcraft' && scp -r 'dbc' 'maps' 'vmaps' 'mmaps' 'Cameras' espionage724@192.168.1.152:~ 
- 
-===== Cleanup on Client ===== 
- 
-  * :!: Run on the machine that did the content extraction 
- 
-  gio open ~/'Wine Prefixes/World of Warcraft 3.3.5/drive_c/Program Files/World of Warcraft' 
- 
-==== Archive ==== 
- 
-  * In-case the data is wanted for a later restore instead of re-extraction 
- 
-  cd ~/'.wine/World of Warcraft 1.12.x/drive_c/Program Files/World of Warcraft' && tar -cvzf ~/'Downloads/1.12.x-content-'$(date +%Y-%m-%d)'.tar.gz' 'dbc' 'maps' 'vmaps' 'mmaps' 'Cameras' && cd ~ && sync 
- 
-===== Move Content on Server ===== 
- 
-  * Moves the ''dbc'', ''maps'', ''vmaps'', ''mmaps'', and ''Cameras'' folders from the main user's ''~'' into the ''bin'' folder 
-  * :!: Run on the machine that is **running the server** 
- 
-  ls ~/'dbc' ~/'maps' ~/'vmaps' ~/'mmaps' ~/'Cameras' > '/dev/null' && sudo rm -Rf '/var/lib/cmangos/Projects/cmangos-classic/run/bin/dbc' '/var/lib/cmangos/Projects/cmangos-classic/run/bin/maps' '/var/lib/cmangos/Projects/cmangos-classic/run/bin/vmaps' '/var/lib/cmangos/Projects/cmangos-classic/run/bin/mmaps' '/var/lib/cmangos/Projects/cmangos-classic/run/bin/Cameras' && cd ~ && sudo mv 'dbc' 'maps' 'vmaps' 'mmaps' 'Cameras' '/var/lib/cmangos/Projects/cmangos-classic/run/bin' && sudo chown -R 'cmangos':'cmangos' '/var/lib/cmangos/Projects/cmangos-classic/run/bin' && sync 
- 
-  sudo restorecon -F -I -R '/var/lib/cmangos' && sync 
- 
-====== Settings ====== 
- 
-===== realmd ===== 
- 
-==== Copy ==== 
- 
-  sudo su 'cmangos' -s '/usr/bin/bash' 
- 
-  cp ~/'Projects/cmangos-classic/run/etc/realmd.conf.dist' ~/'Projects/cmangos-classic/run/etc/realmd.conf' 
- 
-==== Settings ==== 
- 
-  sudo su 'cmangos' -s '/usr/bin/bash' 
- 
-  ~/'Projects/cmangos-classic/run/etc/realmd.conf' 
- 
-<code> 
-x</code> 
- 
-===== mangosd ===== 
- 
-==== Copy ==== 
- 
-  sudo su 'cmangos' -s '/usr/bin/bash' 
- 
-  cp ~/'Projects/cmangos-classic/run/etc/mangosd.conf.dist' ~/'Projects/cmangos-classic/run/etc/mangosd.conf' 
- 
-==== Settings ==== 
- 
-  sudo su 'cmangos' -s '/usr/bin/bash' 
- 
-  ~/'Projects/cmangos-classic/run/etc/mangosd.conf' 
- 
-<code> 
-x</code> 
- 
-====== Create GM Account ====== 
- 
-  * Starting the ''worldserver'' by itself and first is intentional 
- 
-  sudo su 'trinity' -s '/usr/bin/bash' 
- 
-  cd ~/'Projects/trinity-335/run/bin' && ~/'Projects/trinity-335/run/bin/worldserver' 
- 
-  account create Espionage724 x 
- 
-  account set gmlevel Espionage724 3 
- 
-  server shutdown 1 
- 
-====== Other Settings ====== 
- 
-===== Disable Console ===== 
- 
-==== Config ==== 
- 
-  * This prevents the system log from having unnecessary console spam 
-  * :!: To be done **after** creating the initial GM account 
-  * Any additional console use should come from ''telnet'' from a remote machine on the local network 
-  * :!: Credentials for the remote console are the same as the GM account created above 
- 
-  sudo su 'trinity' -s '/usr/bin/bash' 
- 
-  nano ~/'Projects/trinity-335/run/etc/worldserver.conf' 
- 
-  Console.Enable = 0 
- 
-==== telnet ==== 
- 
-  telnet '192.168.1.152' '3443' 
- 
-  server shutdown 1 
- 
-===== Realm Information ===== 
- 
-  * To be done after databases are initialized 
-  * Applies to the first realm 
-  * :!: If running a LAN server, change ''wow.realmofespionage.xyz'' to LAN IP 
- 
-  sudo mysql 
- 
-  UPDATE `authserver`.`realmlist` SET `name` = 'RoE (WotLK)', `address` = 'wow.realmofespionage.xyz' WHERE `realmlist`.`id` = 1; 
- 
-===== Two-Factor Authentication ===== 
- 
-  * To be done after databases are initialized 
-  * Applies to the first account 
-  * :!: ''token_key'' must contain and not exceed 16 characters and can only contain characters A-Z and numbers 2-7 ((in other words, ''token_key'' requires a 16-character Base32 string)) 
-  * Add key to Authenticator app 
-  * Authenticator will be prompted from the game client on each log-in 
- 
-  mysql -u root -p 
- 
-  UPDATE `authserver`.`account` SET `token_key` = 'x' WHERE `account`.`id` = 1 
- 
-===== SOAP ===== 
- 
-  * TODO: Re-figure out how SOAP works 
- 
-====== Services ====== 
- 
-===== authserver ===== 
- 
-==== Service ==== 
- 
-  sudo -e '/etc/systemd/system/tc-335-auth.service' && sudo systemctl daemon-reload && sudo systemctl enable 'tc-335-auth' 
- 
-<code> 
-[Unit] 
-Description=TrinityCore 3.3.5 authserver 
-Wants=network-online.target 
-After=network-online.target mysqld.service 
- 
-[Service] 
-Type=simple 
-User=trinity 
-Group=trinity 
-WorkingDirectory=/var/lib/trinity/Projects/trinity-335/run/bin 
-ExecStart='/var/lib/trinity/Projects/trinity-335/run/bin/authserver' -c '/var/lib/trinity/Projects/trinity-335/run/etc/authserver.conf' 
-Restart=always 
-RestartSec=5 
- 
-[Install] 
-WantedBy=multi-user.target</code> 
- 
-=== SELinux === 
- 
-  * :!: May have to re-run this series of commands over-time 
- 
-  sudo setenforce 0 
- 
-  sudo systemctl start 'tc-335-auth' && sudo systemctl status 'tc-335-auth' -l 
- 
-  mkdir -p ~/'policies' && cd ~/'policies' && sudo grep 'authserver' '/var/log/audit/audit.log' | sudo audit2allow -M 'authserver' && sudo semodule -i 'authserver.pp' && cd ~ 
- 
-  sudo setenforce 1 
- 
-  nano ~/'policies/authserver.te' 
- 
-===== worldserver ===== 
- 
-  * :!: Make sure worldserver's Console is disabled before starting the ''worldserver'' service (see [[servers:games:trinitycore_3.3.5#disable_console|configuration]]) 
- 
-==== Service ==== 
- 
-  sudo -e '/etc/systemd/system/tc-335-world.service' && sudo systemctl daemon-reload && sudo systemctl enable 'tc-335-world' 
- 
-<code> 
-[Unit] 
-Description=TrinityCore 3.3.5 worldserver 
-Wants=network-online.target 
-After=network-online.target mysqld.service 
- 
-[Service] 
-Type=simple 
-User=trinity 
-Group=trinity 
-WorkingDirectory=/var/lib/trinity/Projects/trinity-335/run/bin 
-ExecStart='/var/lib/trinity/Projects/trinity-335/run/bin/worldserver' -c '/var/lib/trinity/Projects/trinity-335/run/etc/worldserver.conf' 
-Restart=always 
-RestartSec=5 
- 
-[Install] 
-WantedBy=multi-user.target</code> 
- 
-=== SELinux === 
- 
-  * :!: May have to re-run this series of commands over-time 
- 
-  sudo setenforce 0 
- 
-  sudo systemctl start 'tc-335-world' && sudo systemctl status 'tc-335-world' -l 
- 
-  mkdir -p ~/'policies' && cd ~/'policies' && sudo grep 'worldserver' '/var/log/audit/audit.log' | sudo audit2allow -M 'worldserver' && sudo semodule -i 'worldserver.pp' && cd ~ 
- 
-  sudo setenforce 1 
- 
-  nano ~/'policies/worldserver.te' 
- 
-===== Information ===== 
- 
-  * :!: Explanation of the update process and following services 
- 
-  - Pull-in updated sources and compile TC (1:00) 
-  - Stop TC auth and world services (3:00) 
-  - Install updated-compiled TC (3:02:30) 
-  - Start TC auth and world services (3:05) 
- 
-===== Updater ===== 
- 
-==== Service ==== 
- 
-  * :!: Change ''make --jobs=2'' as-needed 
- 
-  sudo -e '/etc/systemd/system/tc-335-up.service' 
- 
-<code> 
-[Service] 
-User=trinity 
-Group=trinity 
-Type=oneshot 
-WorkingDirectory=/var/lib/trinity/Projects/trinity-335/build 
-Environment='CC=/usr/bin/clang' 
-Environment='CXX=/usr/bin/clang++' 
-ExecStartPre='/usr/bin/make' clean 
-ExecStartPre='/usr/bin/git' -C '/var/lib/trinity/Projects/trinity-335/src' pull origin '3.3.5' 
-ExecStartPre='/usr/bin/sync' 
-ExecStart='/usr/bin/cmake' '/var/lib/trinity/Projects/trinity-335/src' -DCMAKE_INSTALL_PREFIX='/var/lib/trinity/Projects/trinity-335/run' -DTOOLS='1' 
-ExecStart='/usr/bin/make' --jobs='2' 
-ExecStartPost='/usr/bin/sync'</code> 
- 
-==== Timer ==== 
- 
-  * Every day at ''01:00:00'' 
- 
-  sudo -e '/etc/systemd/system/tc-335-up.timer' && sudo systemctl daemon-reload && sudo systemctl enable 'tc-335-up.timer' --now 
- 
-<code> 
-[Unit] 
-Description=TrinityCore 3.3.5 Git Updater and Compiler 
-Wants=network-online.target 
-After=network-online.target 
- 
-[Timer] 
-OnCalendar=*-*-* 01:00:00 
-Persistent=true 
- 
-[Install] 
-WantedBy=timers.target</code> 
- 
-===== Stopper ===== 
- 
-==== Service ==== 
- 
-  sudo -e '/etc/systemd/system/tc-335-stop.service' 
- 
-<code> 
-[Service] 
-Type=oneshot 
-ExecStart='/usr/bin/systemctl' stop 'tc-335-auth' 
-ExecStart='/usr/bin/systemctl' stop 'tc-335-world' 
-ExecStartPost='/usr/bin/sync'</code> 
- 
-==== Timer ==== 
- 
-  * Every day at ''03:00:00'' 
- 
-  sudo -e '/etc/systemd/system/tc-335-stop.timer' && sudo systemctl daemon-reload && sudo systemctl enable 'tc-335-stop.timer' --now 
- 
-<code> 
-[Unit] 
-Description=TrinityCore 3.3.5 Services Stopper 
-Wants=network-online.target mysqld.service 
-After=network-online.target 
- 
-[Timer] 
-OnCalendar=*-*-* 03:00:00 
-Persistent=true 
- 
-[Install] 
-WantedBy=timers.target</code> 
- 
-===== Post-updater ===== 
- 
-==== Service ==== 
- 
-  sudo -e '/etc/systemd/system/tc-335-up-post.service' 
- 
-<code> 
-[Service] 
-User=trinity 
-Group=trinity 
-Type=oneshot 
-WorkingDirectory=/var/lib/trinity/Projects/trinity-335/build 
-ExecStart='/usr/bin/make' install 
-ExecStartPost='/usr/bin/sync'</code> 
- 
-==== Timer ==== 
- 
-  * Every day at ''03:02:30'' 
- 
-  sudo -e '/etc/systemd/system/tc-335-up-post.timer' && sudo systemctl daemon-reload && sudo systemctl enable 'tc-335-up-post.timer' --now 
- 
-<code> 
-[Unit] 
-Description=TrinityCore 3.3.5 Post-Updater 
-Wants=network-online.target 
-After=network-online.target 
- 
-[Timer] 
-OnCalendar=*-*-* 03:02:30 
-Persistent=true 
- 
-[Install] 
-WantedBy=timers.target</code> 
- 
-===== Restarter ===== 
- 
-==== Service ==== 
- 
-  sudo -e '/etc/systemd/system/tc-335-restart.service' 
- 
-<code> 
-[Service] 
-Type=oneshot 
-ExecStart='/usr/bin/systemctl' start 'tc-335-auth' 
-ExecStart='/usr/bin/systemctl' start 'tc-335-world' 
-ExecStartPost='/usr/bin/sync'</code> 
- 
-==== Timer ==== 
- 
-  * Every day at ''03:05:00'' 
- 
-  sudo -e '/etc/systemd/system/tc-335-restart.timer' && sudo systemctl daemon-reload && sudo systemctl enable 'tc-335-restart.timer' --now 
- 
-<code> 
-[Unit] 
-Description=TrinityCore 3.3.5 Services Restarter 
-Wants=network-online.target mysqld.service 
-After=network-online.target 
- 
-[Timer] 
-OnCalendar=*-*-* 03:05:00 
-Persistent=true 
- 
-[Install] 
-WantedBy=timers.target</code> 
- 
-===== Database Backup ===== 
- 
-  * This backs up an archive to the local disk 
-  * :!: Everything below this line may need re-factored and isn't tested with the updated notes as of 2019/02/19 
- 
-==== authserver ==== 
- 
-=== Database Auth === 
- 
-  sudo -H -u 'mysql' -e '/var/lib/mysql/auth/authserver' && sudo chmod '600' '/var/lib/mysql/auth/authserver' 
- 
-  [mysqldump] 
-  user=authserver 
-  password=x 
- 
-=== Service === 
- 
-  mkdir -p ~/'backups' && sudo -H -u 'mysql' mkdir -p '/var/lib/mysql/tmp' && sudo -e '/etc/systemd/system/authserver-db.service' && sudo sed -i 's/'CHANGEME'/'$USER'/g' '/etc/systemd/system/authserver-db.service' 
- 
-  [Service] 
-  Type=oneshot 
-  WorkingDirectory=/var/lib/mysql/tmp 
-  ExecStartPre='/usr/bin/mysqldump' --defaults-extra-file='/var/lib/mysql/auth/authserver' --single-transaction 'authserver' -r '/var/lib/mysql/tmp/authserver.sql' 
-  ExecStart='/usr/bin/gzip' -f '/var/lib/mysql/tmp/authserver.sql' 
-  ExecStart='/usr/bin/bash' -c '"/usr/bin/mv" "/var/lib/mysql/tmp/authserver.sql.gz" "/home/CHANGEME/backups/authserver-database-auto-"$$(date +%%Y-%%m-%%d)".sql.gz"' 
-  ExecStartPost='/usr/bin/sync' 
- 
-=== Timer === 
- 
-  * This happens daily 
- 
-  sudo -e '/etc/systemd/system/authserver-db.timer' && sudo systemctl daemon-reload && sudo systemctl enable 'authserver-db.timer' --now && sudo systemctl start 'authserver-db' && sudo systemctl status 'authserver-db' -l 
- 
-  [Unit] 
-  Description=TrinityCore (authserver) Database Backup 
-  After=mysqld.service 
-   
-  [Timer] 
-  OnCalendar=*-*-* 03:40:00 
-  Persistent=true 
-   
-  [Install] 
-  WantedBy=timers.target 
- 
-==== characters ==== 
- 
-=== Database Auth === 
- 
-  sudo -H -u 'mysql' -e '/var/lib/mysql/auth/characters' && sudo chmod '600' '/var/lib/mysql/auth/characters' 
- 
-  [mysqldump] 
-  user=characters 
-  password=x 
- 
-=== Service === 
- 
-  mkdir -p ~/'backups' && sudo -H -u 'mysql' mkdir -p '/var/lib/mysql/tmp' && sudo -e '/etc/systemd/system/characters-db.service' && sudo sed -i 's/'CHANGEME'/'$USER'/g' '/etc/systemd/system/characters-db.service' 
- 
-  [Service] 
-  Type=oneshot 
-  WorkingDirectory=/var/lib/mysql/tmp 
-  ExecStartPre='/usr/bin/mysqldump' --defaults-extra-file='/var/lib/mysql/auth/characters' --single-transaction 'characters' -r '/var/lib/mysql/tmp/characters.sql' 
-  ExecStart='/usr/bin/gzip' -f '/var/lib/mysql/tmp/characters.sql' 
-  ExecStart='/usr/bin/bash' -c '"/usr/bin/mv" "/var/lib/mysql/tmp/characters.sql.gz" "/home/CHANGEME/backups/characters-database-auto-"$$(date +%%Y-%%m-%%d)".sql.gz"' 
-  ExecStartPost='/usr/bin/sync' 
- 
-=== Timer === 
- 
-  * This happens daily 
- 
-  sudo -e '/etc/systemd/system/characters-db.timer' && sudo systemctl daemon-reload && sudo systemctl enable 'characters-db.timer' --now && sudo systemctl start 'characters-db' && sudo systemctl status 'characters-db' -l 
- 
-  [Unit] 
-  Description=TrinityCore (characters) Database Backup 
-  After=mysqld.service 
-   
-  [Timer] 
-  OnCalendar=*-*-* 03:41:00 
-  Persistent=true 
-   
-  [Install] 
-  WantedBy=timers.target 
- 
-====== Backup ====== 
- 
-  * Create backup archive on server and transfer to client computer 
- 
-===== Server ===== 
- 
-==== Stop Services ==== 
- 
-**** 
- 
-  sudo systemctl stop authserver worldserver 
- 
-==== Backup Database ==== 
- 
-  sudo mysqldump --defaults-extra-file='/var/lib/mysql/auth/authserver' --single-transaction 'authserver' -r ~/'authserver-database-manual-'$(date +%Y-%m-%d)'.sql' && sync 
- 
-  sudo mysqldump --defaults-extra-file='/var/lib/mysql/auth/characters' --single-transaction 'characters' -r ~/'characters-database-manual-'$(date +%Y-%m-%d)'.sql' && sync 
- 
-==== Start Services ==== 
- 
-**** 
- 
-  sudo systemctl start authserver worldserver 
- 
-===== Client ===== 
- 
-==== Transfer Files To Client ==== 
- 
-**** 
- 
-  scp espionage724@192.168.1.152:~/'authserver-database-'*'.sql' espionage724@192.168.1.152:~/'characters-database-'*'.sql' ~/'Downloads' && sync 
- 
-====== Restore ====== 
- 
-===== Client ===== 
- 
-==== Uncompress Database ==== 
- 
-  * This is only needed if restoring an **automated** database backup ((manual doesn't gzip)) 
- 
-  gunzip ~/'Downloads/authserver-database-'*'.sql.gz' 
- 
-  gunzip ~/'Downloads/characters-database-'*'.sql.gz' 
- 
-==== Transfer Files To Server ==== 
- 
-**** 
- 
-  scp ~/'Downloads/authserver-database-'*'.sql' ~/'Downloads/characters-database-'*'.sql' espionage724@192.168.1.152:~ 
- 
-==== Remove Files ==== 
- 
-**** 
- 
-  rm -f ~/'Downloads/authserver-database-'*'.sql' ~/'Downloads/characters-database-'*'.sql' && sync 
- 
-===== Server ===== 
- 
-==== Stop Services ==== 
- 
-**** 
- 
-  sudo systemctl stop authserver worldserver 
- 
-==== Drop Previous Database ==== 
- 
-  sudo mysql 
- 
-  DROP DATABASE authserver; 
- 
-  DROP DATABASE characters; 
- 
-  FLUSH TABLES; 
- 
-  EXIT 
- 
-==== Re-create Databases ==== 
- 
-  sudo mysql 
- 
-  CREATE DATABASE authserver; 
- 
-  CREATE DATABASE characters; 
- 
-  EXIT 
- 
-==== Restore Database ==== 
- 
-  sudo mysql 'authserver' < ~/'authserver-database-'*'.sql' && sync 
- 
-  sudo mysql 'characters' < ~/'characters-database-'*'.sql' && sync 
- 
-==== Reapply Permissions ==== 
- 
-  sudo mysql 
- 
-  GRANT ALL PRIVILEGES ON authserver.* to 'authserver'@'localhost' IDENTIFIED BY 'x'; 
- 
-  GRANT ALL PRIVILEGES ON characters.* to 'characters'@'localhost' IDENTIFIED BY 'x'; 
- 
-  FLUSH PRIVILEGES; 
- 
-  EXIT 
- 
-==== Start Services ==== 
- 
-**** 
- 
-  sudo systemctl start authserver worldserver 
- 
-==== Remove Backups ==== 
- 
-  * Verify that TrinityCore works before running 
- 
-  rm ~/'authserver-database-'*'.sql' ~/'characters-database-'*'.sql' && sync