wahlfeld / valheim-on-aws

Apache License 2.0
27 stars 10 forks source link

Backups not working due to game client changing .db location #21

Closed Nipplechips closed 1 year ago

Nipplechips commented 1 year ago

Had an issue where backups were not appearing in the S3 bucket, this is because the scripts that are copied to the server look for the .db and .fwl files in "/home/${username}/.config/unity3d/IronGate/Valheim/worlds/${world_name}" where as the game client that was installed was saving these files to "/home/${username}/.config/unity3d/IronGate/Valheim/worlds_local/${world_name}. Easily resolved by adjusting the scripts within /module/local/ but cause issues when our community was 100+ days into the game.

Additionally, this setup does not assign a key_name to the aws_spot_instance_request resource. This meant that I was not able to SSH into the EC2 instance and troubleshoot the backup issue in the first place. Would be good idea in my opinion to define a key_name resource as I believe Terraform will create one if it doesnt already exist.

wahlfeld commented 1 year ago

Sure, will take a look at this today, thanks for reporting. Regarding keys, suggest you try using AWS SSM to shell onto the server, as it doesn't require any keys or further setup. E.g.,

> aws ec2 describe-instances --query 'Reservations[].Instances[].{Name: Tags[?Key==`Name`].Value | [0], InstanceId: InstanceId}' --output table

-------------------------------------------
|            DescribeInstances            |
+----------------------+------------------+
|      InstanceId      |      Name        |
+----------------------+------------------+
|  i-02fd2e82b75a07703 |  valheim-server  |
+----------------------+------------------+

> aws ssm start-session --target i-02fd2e82b75a07703

Starting session with SessionId: curtis.wahlfeld@outlook.com-06589d2a738a5bdf8
> $ bash
> ssm-user@ip-172-31-32-122:/var/snap/amazon-ssm-agent/6312$ cd /home/
> ssm-user@ip-172-31-32-122:/home$ ls
ssm-user  ubuntu  vhserver
wahlfeld commented 1 year ago

I've done some testing just now and I'm finding the behaviour of backups still isn't quite right, e.g., when I stop the server (using a spot instance) I'm not seeing the backup being created in S3.

Nipplechips commented 1 year ago

I found that when I logged onto the instance, the aws s3 cp command wouldnt work because the CLI couldnt find valid aws credentials. I had to generate a session in AWS identity centre and then set env variables on the instance for the CLI tool to pick it up.