add backup job
This commit is contained in:
parent
6bb66f3e21
commit
fae126b438
2 changed files with 40 additions and 0 deletions
39
backup.nix
Normal file
39
backup.nix
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
user = "misskey-backup";
|
||||||
|
group = user;
|
||||||
|
|
||||||
|
# shell script file to be sourced. must have values "bucket" "prefix" and "s3cfg"
|
||||||
|
backupConfigFile = "/etc/misskey-backup";
|
||||||
|
backupScript = pkgs.writeShellApplication {
|
||||||
|
name = "misskey-backup";
|
||||||
|
|
||||||
|
runtimeInputs = with pkgs; [
|
||||||
|
gzip
|
||||||
|
config.services.postgresql.package
|
||||||
|
s3cmd
|
||||||
|
coreutils
|
||||||
|
];
|
||||||
|
|
||||||
|
text = ''
|
||||||
|
source "${backupConfigFile}"
|
||||||
|
pg_dump misskey | gzip | s3cmd put --config "$s3cfg" - "s3://$bucket/$prefix/misskey-pgdump-$(date --iso-8601).sql.gz"
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
in {
|
||||||
|
users.users."${user}" = {
|
||||||
|
isSystemUser = true;
|
||||||
|
inherit group;
|
||||||
|
};
|
||||||
|
users.groups."${group}" = { };
|
||||||
|
services.postgresql.ensureUsers = [{ name = user; }];
|
||||||
|
|
||||||
|
services.cron = {
|
||||||
|
enable = true;
|
||||||
|
systemCronJobs = [
|
||||||
|
# run every monday at ass in the morning, EST"
|
||||||
|
"0 8 0 0 1 ${user} ${backupScript}"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
|
@ -6,6 +6,7 @@
|
||||||
./ogdo.nix
|
./ogdo.nix
|
||||||
./postfix.nix
|
./postfix.nix
|
||||||
./nebula.nix
|
./nebula.nix
|
||||||
|
./backup.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
nix.settings = {
|
nix.settings = {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue