Compare commits
3 commits
d734274b8a
...
0ebd6794d7
Author | SHA1 | Date | |
---|---|---|---|
0ebd6794d7 | |||
84e4d13ced | |||
c3e53a4c36 |
2 changed files with 14 additions and 2 deletions
14
backup.nix
14
backup.nix
|
@ -12,6 +12,8 @@ let
|
|||
|
||||
backupConfigFile = "/etc/misskey-backup/conf";
|
||||
s3Cfg = "/etc/misskey-backup/s3cfg";
|
||||
|
||||
tarRedisStdoutCmd = "tar -cz -C /var/lib/redis-misskey .";
|
||||
in {
|
||||
users.users."${user}" = {
|
||||
isSystemUser = true;
|
||||
|
@ -42,6 +44,8 @@ in {
|
|||
];
|
||||
|
||||
script = ''
|
||||
set -o pipefail
|
||||
|
||||
ageRecipient="age17ckyc69njpryytc63ynn545jswyucg28k5xg3043g3j6q38dxqwq0wzhm2"
|
||||
bucket="$(grep 'bucket=' < "${backupConfigFile}" | sed 's/bucket \?= \?//g')"
|
||||
prefix="$(grep 'prefix=' < "${backupConfigFile}" | sed 's/prefix \?= \?//g')"
|
||||
|
@ -62,7 +66,7 @@ in {
|
|||
pg_dump misskey | gzip | upload "pg_dump.sql.gz"
|
||||
|
||||
echo "Uploading redis database..."
|
||||
tar -cz -C /var/lib/redis-misskey . | upload "redis.tar.gz"
|
||||
sudo ${tarRedisStdoutCmd} | upload "redis.tar.gz"
|
||||
|
||||
echo "Backup complete to '$s3Dir'"
|
||||
'';
|
||||
|
@ -73,4 +77,12 @@ in {
|
|||
};
|
||||
|
||||
systemd.timers.misskey-backup = { timerConfig.Persistent = true; };
|
||||
|
||||
security.sudo.extraRules = [{
|
||||
groups = [ group ];
|
||||
commands = [{
|
||||
command = tarRedisStdoutCmd;
|
||||
options = [ "NOPASSWD" ];
|
||||
}];
|
||||
}];
|
||||
}
|
||||
|
|
|
@ -18,6 +18,6 @@
|
|||
enable = true;
|
||||
selector = "default";
|
||||
socket = "inet:8891@127.0.0.1";
|
||||
domains = "csl:${config.networking.fqdn}";
|
||||
domains = "csl:${config.networking.fqdn},admin.${config.networking.fqdn}";
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue