Make tmodloader backup script much more robust

This commit is contained in:
Salt 2020-09-29 05:17:10 -05:00
parent eb70ca095f
commit 34ea53675f

View File

@ -1,7 +1,7 @@
#! /bin/bash
#
# terraria.sh
# Backup script for Gitea. Meant to be sourced by our main backup script
# Backup script for tModLoader. Meant to be sourced by our main backup script
# Copyright (C) 2020 Vintage Salt <rehashedsalt@cock.li>
#
# Distributed under terms of the MIT license.
@ -42,7 +42,14 @@ fi
# WE MAKE BACKUP NOW SERGEI
if cd "$OUTDIR"; then
log "Initiating terraria dump"
su terraria -c "cp \"$TERRARIADIR/worlds/world.wld\" \"$OUTDIR/world-$(date -Iseconds).wld\""
outworld="world-$(date -Iseconds)"
su terraria -c "cp \"$TERRARIADIR/worlds/world.wld\" \"$OUTDIR/$outworld.wld\""
su terraria -c "cp \"$TERRARIADIR/worlds/world.twld\" \"$OUTDIR/$outworld.twld\""
{% if aws.backup_bucket is defined %}
log "Backing up to S3"
aws s3 cp "$OUTDIR/$outworld.wld" "s3://{{ aws.backup_bucket}}/tmodloader/{{ terraria_name }}/world-$(date -Iseconds).wld" --storage-class STANDARD
aws s3 cp "$OUTDIR/$outworld.twld" "s3://{{ aws.backup_bucket}}/tmodloader/{{ terraria_name }}/world-$(date -Iseconds).twld" --storage-class STANDARD
{% endif %}
else
log "Could not change directory: $OUTDIR"
return 3