From 24094cad316f05085494e5233a619b339d1ebd9c Mon Sep 17 00:00:00 2001 From: jaina heartles Date: Wed, 25 Dec 2024 15:33:20 -0500 Subject: [PATCH] use bash function to upload --- backup.nix | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/backup.nix b/backup.nix index 8970461..b2ad438 100644 --- a/backup.nix +++ b/backup.nix @@ -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'" '';