use bash function to upload

This commit is contained in:
jaina heartles 2024-12-25 15:33:20 -05:00
parent 983f47440f
commit 24094cad31

View file

@ -32,14 +32,20 @@ let
s3Dir="s3://$bucket/\$\{prefix}misskey-$(date --iso-8601)"
echo "Uploading backups to '$s3Dir'"
function upload () {
name="$1"
s3cmd put --config "${s3Cfg}" - "$s3Dir/$name"
}
echo "Uploading config"
tar -cz -C /srv/misskey/.config . | s3cmd put --config "${s3Cfg}" - "$s3Dir/config.tar.gz"
tar -cz -C /srv/misskey/.config . | upload "config.tar.gz"
echo "Dumping postgres database..."
pg_dump misskey | gzip | s3cmd put --config "${s3Cfg}" - "$s3Dir/pg_dump.sql.gz"
pg_dump misskey | gzip | upload "pg_dump.sql.gz"
echo "Uploading redis database..."
tar -cz -C /var/lib/redis-misskey . | s3cmd put --config "${s3Cfg}" - "$s3Dir/redis.tar.gz"
tar -cz -C /var/lib/redis-misskey . | upload "redis.tar.gz"
echo "Backup complete to '$s3Dir'"
'';