🚀 postgresqlBackups (finally)
This commit is contained in:
parent
bd132825d4
commit
9a5ce7b946
@ -10,6 +10,7 @@
|
||||
../../modules/home-assistant
|
||||
../../modules/matrix
|
||||
../../modules/pleroma
|
||||
../../modules/postgresql
|
||||
../../modules/sops
|
||||
];
|
||||
|
||||
|
@ -12,31 +12,34 @@ in
|
||||
};
|
||||
users.groups.git = { };
|
||||
|
||||
services.gitea = {
|
||||
enable = true;
|
||||
user = "git";
|
||||
domain = "walkah.dev";
|
||||
appName = "walkah forge";
|
||||
rootUrl = "https://walkah.dev/";
|
||||
httpAddress = "0.0.0.0";
|
||||
httpPort = 8003;
|
||||
log.level = "Error";
|
||||
lfs.enable = true;
|
||||
|
||||
disableRegistration = true;
|
||||
cookieSecure = true;
|
||||
|
||||
settings = {
|
||||
other.SHOW_FOOTER_VERSION = false;
|
||||
repository.DEFAULT_BRANCH = "main";
|
||||
server.SSH_DOMAIN = "git.walkah.dev";
|
||||
};
|
||||
|
||||
dump.enable = false;
|
||||
|
||||
database = {
|
||||
type = "postgres";
|
||||
services = {
|
||||
gitea = {
|
||||
enable = true;
|
||||
user = "git";
|
||||
domain = "walkah.dev";
|
||||
appName = "walkah forge";
|
||||
rootUrl = "https://walkah.dev/";
|
||||
httpAddress = "0.0.0.0";
|
||||
httpPort = 8003;
|
||||
log.level = "Error";
|
||||
lfs.enable = true;
|
||||
|
||||
disableRegistration = true;
|
||||
cookieSecure = true;
|
||||
|
||||
settings = {
|
||||
other.SHOW_FOOTER_VERSION = false;
|
||||
repository.DEFAULT_BRANCH = "main";
|
||||
server.SSH_DOMAIN = "git.walkah.dev";
|
||||
};
|
||||
|
||||
dump.enable = false;
|
||||
|
||||
database = {
|
||||
type = "postgres";
|
||||
user = "git";
|
||||
};
|
||||
};
|
||||
postgresqlBackup.databases = [ "gitea" ];
|
||||
};
|
||||
}
|
||||
|
@ -9,5 +9,6 @@
|
||||
ensurePermissions = { "DATABASE hass" = "ALL PRIVILEGES"; };
|
||||
}];
|
||||
};
|
||||
postgresqlBackup.databases = [ "hass" ];
|
||||
};
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
LC_CTYPE = "C";
|
||||
'';
|
||||
};
|
||||
postgresqlBackup.databases = [ "matrix" ];
|
||||
|
||||
matrix-synapse = {
|
||||
enable = true;
|
||||
|
@ -13,5 +13,6 @@
|
||||
ensurePermissions = { "DATABASE pleroma" = "ALL PRIVILEGES"; };
|
||||
}];
|
||||
};
|
||||
postgresqlBackup.databases = [ "pleroma" ];
|
||||
};
|
||||
}
|
||||
|
38
modules/postgresql/default.nix
Normal file
38
modules/postgresql/default.nix
Normal file
@ -0,0 +1,38 @@
|
||||
{ pkgs, config, ... }: {
|
||||
services = {
|
||||
postgresql = {
|
||||
enable = true;
|
||||
};
|
||||
|
||||
postgresqlBackup = {
|
||||
enable = true;
|
||||
};
|
||||
};
|
||||
|
||||
# Postgres upgrades: https://nixos.org/manual/nixos/stable/index.html#module-services-postgres-upgrading
|
||||
environment.systemPackages = [
|
||||
(pkgs.writeScriptBin "upgrade-pg-cluster" ''
|
||||
set -eux
|
||||
# XXX it's perhaps advisable to stop all services that depend on postgresql
|
||||
systemctl stop postgresql
|
||||
|
||||
# XXX replace `<new version>` with the psqlSchema here
|
||||
export NEWDATA="/var/lib/postgresql/11.1"
|
||||
|
||||
# XXX specify the postgresql package you'd like to upgrade to
|
||||
export NEWBIN="${pkgs.postgresql_12}/bin"
|
||||
|
||||
export OLDDATA="${config.services.postgresql.dataDir}"
|
||||
export OLDBIN="${config.services.postgresql.package}/bin"
|
||||
|
||||
install -d -m 0700 -o postgres -g postgres "$NEWDATA"
|
||||
cd "$NEWDATA"
|
||||
sudo -u postgres $NEWBIN/initdb -D "$NEWDATA"
|
||||
|
||||
sudo -u postgres $NEWBIN/pg_upgrade \
|
||||
--old-datadir "$OLDDATA" --new-datadir "$NEWDATA" \
|
||||
--old-bindir $OLDBIN --new-bindir $NEWBIN \
|
||||
"$@"
|
||||
'')
|
||||
];
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user