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'" '';