From 4521d404ae7e04b7955f351ed5211cc60cbdbdc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98ystein=20Tveit?= Date: Sun, 22 Dec 2024 23:50:35 +0100 Subject: [PATCH] WIP --- hosts/bicep/services/mysql.nix | 19 +++++++++++++------ hosts/bicep/services/postgres.nix | 17 ++++++++++++----- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/hosts/bicep/services/mysql.nix b/hosts/bicep/services/mysql.nix index 4c24031..7add61f 100644 --- a/hosts/bicep/services/mysql.nix +++ b/hosts/bicep/services/mysql.nix @@ -64,19 +64,18 @@ in script = let rotations = 10; - sshTarget1 = "root@isvegg.pvv.ntnu.no:/mnt/backup1/bicep/mysql"; - sshTarget2 = "root@isvegg.pvv.ntnu.no:/mnt/backup2/bicep/mysql"; + # rsyncTarget = "root@isvegg.pvv.ntnu.no:/mnt/backup1/bicep/mysql"; + rsyncTarget = "/data/backup/mysql"; in '' set -eo pipefail - mysqldump | gzip -c -9 --rsyncable > "${backupDir}/$(date --iso-8601)-dump.sql.gz" + mysqldump --all-databases | gzip -c -9 --rsyncable > "${backupDir}/$(date --iso-8601)-dump.sql.gz" while [ $(ls -1 "${backupDir}" | wc -l) -gt ${toString rotations} ]; do rm $(find "${backupDir}" -type f -printf '%T+ %p\n' | sort | head -n 1 | cut -d' ' -f2) done - rsync -avz --delete "${backupDir}" '${sshTarget1}' - rsync -avz --delete "${backupDir}" '${sshTarget2}' + rsync -avz --delete "${backupDir}" '${rsyncTarget}' ''; serviceConfig = { @@ -84,7 +83,15 @@ in User = "mysql"; Group = "mysql"; UMask = "0077"; - ReadWritePaths = [ backupDir ]; + + Nice = 19; + IOSchedulingClass = "best-effort"; + IOSchedulingPriority = 7; + + ReadWritePaths = [ + backupDir + "/data/backup/mysql" # NOTE: should not be part of this option once rsyncTarget is remote + ]; }; startAt = "*-*-* 02:15:00"; diff --git a/hosts/bicep/services/postgres.nix b/hosts/bicep/services/postgres.nix index 12c126d..64beb5d 100644 --- a/hosts/bicep/services/postgres.nix +++ b/hosts/bicep/services/postgres.nix @@ -108,8 +108,8 @@ in script = let rotations = 10; - sshTarget1 = "root@isvegg.pvv.ntnu.no:/mnt/backup1/bicep/postgresql"; - sshTarget2 = "root@isvegg.pvv.ntnu.no:/mnt/backup2/bicep/postgresql"; + # rsyncTarget = "root@isvegg.pvv.ntnu.no:/mnt/backup1/bicep/postgresql"; + rsyncTarget = "/data/backup/postgresql"; in '' set -eo pipefail @@ -119,8 +119,7 @@ in rm $(find "${backupDir}" -type f -printf '%T+ %p\n' | sort | head -n 1 | cut -d' ' -f2) done - rsync -avz --delete "${backupDir}" '${sshTarget1}' - rsync -avz --delete "${backupDir}" '${sshTarget2}' + rsync -avz --delete "${backupDir}" '${rsyncTarget}' ''; serviceConfig = { @@ -128,7 +127,15 @@ in User = "postgres"; Group = "postgres"; UMask = "0077"; - ReadWritePaths = [ backupDir ]; + + Nice = 19; + IOSchedulingClass = "best-effort"; + IOSchedulingPriority = 7; + + ReadWritePaths = [ + backupDir + "/data/backup/postgresql" # NOTE: should not be part of this option once rsyncTarget is remote + ]; }; startAt = "*-*-* 01:15:00";