use bash function to upload
This commit is contained in:
parent
983f47440f
commit
24094cad31
1 changed files with 9 additions and 3 deletions
12
backup.nix
12
backup.nix
|
@ -32,14 +32,20 @@ let
|
||||||
s3Dir="s3://$bucket/\$\{prefix}misskey-$(date --iso-8601)"
|
s3Dir="s3://$bucket/\$\{prefix}misskey-$(date --iso-8601)"
|
||||||
echo "Uploading backups to '$s3Dir'"
|
echo "Uploading backups to '$s3Dir'"
|
||||||
|
|
||||||
|
function upload () {
|
||||||
|
name="$1"
|
||||||
|
|
||||||
|
s3cmd put --config "${s3Cfg}" - "$s3Dir/$name"
|
||||||
|
}
|
||||||
|
|
||||||
echo "Uploading config"
|
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..."
|
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..."
|
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'"
|
echo "Backup complete to '$s3Dir'"
|
||||||
'';
|
'';
|
||||||
|
|
Loading…
Reference in a new issue