Added backup steps.

This commit is contained in:
Eric Myllyoja 2021-12-12 16:18:47 -05:00
parent 17d1022718
commit 17b7a95c03
2 changed files with 49 additions and 2 deletions

View File

@ -260,8 +260,6 @@ sed -i "s/mysql_password=/mysql_password=PASSWORD/g" ~/DarkflameServer/build/wor
sed -i "s|DB_URL = 'mysql+pymysql://<mysql-user>:<mysql-password>@<mysql-host>/<mysql-database>'|DB_URL = 'mysql+pymysql://darkflame:PASSWORD@localhost/darkflame'|g" ~/AccountManager/credentials.py sed -i "s|DB_URL = 'mysql+pymysql://<mysql-user>:<mysql-password>@<mysql-host>/<mysql-database>'|DB_URL = 'mysql+pymysql://darkflame:PASSWORD@localhost/darkflame'|g" ~/AccountManager/credentials.py
``` ```
Make sure to go back to the Cloud Storage page and delete the bucket you created, since you don't need it anymore.
## Run the Server ## Run the Server
Now we are finally going to run the server. Now we are finally going to run the server.
@ -320,6 +318,31 @@ git pull
screen -dmS darkflame-server bash -c "cd ~/DarkflameServer/build/; ./MasterServer" screen -dmS darkflame-server bash -c "cd ~/DarkflameServer/build/; ./MasterServer"
``` ```
## Backup Your Database
Backing up your database is a good idea, as it will allow you to recover your data if you lose your server.
1. Run the following command on your server, then enter your database password.
```bash
mysqldump -u darkflame darkflame --result-file=$HOME/dump.sql -p
```
2. The complete contents of your server's database will be output to the file `~/dump.sql`. This is including, but not limited to:
* Accounts, including usernames and (encrypted) passwords.
* Characters, including their inventory, stats, mission progress, and other data.
* Activity logs, including login and logout times for each player.
* Minigame leaderboards, including scores and times for each player.
3. To get the dump file off the server, run the following command. This will place the file on the Google Cloud Storage instance you created to upload the server-resources file.
```bash
gsutil cp dump.sql gs://BUCKETNAME/dump.sql
```
If the last step fails, see the [Google Cloud Setup Troubleshooting](google-cloud-troubleshooting.md) page.
## Troubleshooting ## Troubleshooting
If you have an issue with any of the above steps, visit the link below to review common questions and troubleshooting tips. If you have an issue with any of the above steps, visit the link below to review common questions and troubleshooting tips.

View File

@ -19,3 +19,27 @@ cd ~/DarkflameServer/build
## I can connect to the Account manager but not to the game! ## I can connect to the Account manager but not to the game!
Make sure your Firewall settings are correct. You may need to edit them such that both the TCP and UDP ports are open. Make sure your Firewall settings are correct. You may need to edit them such that both the TCP and UDP ports are open.
## I tried to write a file to the Google Cloud bucket but got a 403 Forbidden error!
This error occurs when the instance's service account does not have the correct permissions to write to the bucket.
Follow the steps below to configure the instance:
1. Go to the Google Cloud Console and navigate to the Compute Engine tab.
2. Select the instance and click `Stop`. This will temporarily shut down the server and stop the instance. You will be ablt to start it back up later.
3. Click the instance name in the list of instances to open up the details page, then click `Edit` at the top.
4. Scroll down to the subheading named `Access scopes` and select `Allow full access to all Cloud APIs`.
5. Click `Save` to save the changes.
6. Click `Start/Resume` to start the instance back up. Then run the commands from [Run the Server](./google-cloud-setup.md#run-the-server) again.
We've configured the instance and now we need to configure the bucket.
1. Scroll down to the bottom of the details page for the instance and copy the `Service Account` value.
2. Go back to the Storage view and open the details page for your bucket.
3. Move to the `Permissions` tab and click `Add`.
4. For the principal, paste the `Service Account` value from the previous step.
5. Under roles, add the role `Storage Object Viewer`, then click `Add another role` and add the role `Storage Object Creator`.
6. Back on the instance, run `rm -rf ~/.gsutil` to clear out any cached credentials.
Any file write commands should now work.