Rewrite backup services+timers
This commit is contained in:
parent
de7714e8d6
commit
2286d85a68
|
@ -1,4 +1,4 @@
|
||||||
{ pkgs, config, ... }:
|
{ pkgs, config, lib, ... }:
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
../home.nix
|
../home.nix
|
||||||
|
@ -76,10 +76,11 @@
|
||||||
networking.useDHCP = false;
|
networking.useDHCP = false;
|
||||||
|
|
||||||
|
|
||||||
|
## Personal backups
|
||||||
# Syncthing is a bit heavy handed for my needs, so rsync to my NAS instead.
|
# Syncthing is a bit heavy handed for my needs, so rsync to my NAS instead.
|
||||||
systemd = {
|
systemd = {
|
||||||
services.backups = {
|
services.backups = {
|
||||||
description = "Back up personal files";
|
description = "Backup /usr/store to NAS";
|
||||||
wants = [ "usr-drive.mount" ];
|
wants = [ "usr-drive.mount" ];
|
||||||
path = [ pkgs.rsync ];
|
path = [ pkgs.rsync ];
|
||||||
environment = {
|
environment = {
|
||||||
|
@ -90,32 +91,31 @@
|
||||||
rcp() {
|
rcp() {
|
||||||
if [[ -d "$1" && -d "$2" ]]; then
|
if [[ -d "$1" && -d "$2" ]]; then
|
||||||
echo "---- BACKUPING UP $1 TO $2 ----"
|
echo "---- BACKUPING UP $1 TO $2 ----"
|
||||||
rsync -rlptPJ --delete --delete-after \
|
rsync -rlptPJ --chmod=go= --delete --delete-after \
|
||||||
|
--exclude=lost+found/ \
|
||||||
|
--exclude=@eaDir/ \
|
||||||
--include=.git/ \
|
--include=.git/ \
|
||||||
--filter=':- .gitignore' \
|
--filter=':- .gitignore' \
|
||||||
--filter=':- $XDG_CONFIG_HOME/git/ignore' \
|
--filter=':- $XDG_CONFIG_HOME/git/ignore' \
|
||||||
--chmod=go= \
|
|
||||||
"$1" "$2"
|
"$1" "$2"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
rcp "$HOME/projects/" "$SRC_DIR/projects"
|
rcp "$HOME/projects/" "$DEST_DIR/projects"
|
||||||
pushd "$SRC_DIR"
|
rcp "$SRC_DIR/" "$DEST_DIR"
|
||||||
for dirname in *; do
|
|
||||||
rcp "$SRC_DIR/$dirname/" "$DEST_DIR/$dirname"
|
|
||||||
done
|
|
||||||
'';
|
'';
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "oneshot";
|
Type = "oneshot";
|
||||||
Nice = 19;
|
Nice = 19;
|
||||||
IOSchedulingClass = "idle";
|
IOSchedulingClass = "idle";
|
||||||
User = config.user.name;
|
User = config.user.name;
|
||||||
Group = "users";
|
Group = config.user.group;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
timers.backup = {
|
timers.backups = {
|
||||||
wantedBy = [ "timers.target" ];
|
wantedBy = [ "timers.target" ];
|
||||||
partOf = [ "backups.service" ];
|
partOf = [ "backups.service" ];
|
||||||
timerConfig.OnCalendar = "8/2"; # every 4h from 8am
|
timerConfig.OnCalendar = "*-*-* 00,12:00:00";
|
||||||
|
timerConfig.Persistent = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ with lib.my;
|
||||||
extraGroups = [ "wheel" ];
|
extraGroups = [ "wheel" ];
|
||||||
isNormalUser = true;
|
isNormalUser = true;
|
||||||
home = "/home/${name}";
|
home = "/home/${name}";
|
||||||
|
group = "users";
|
||||||
uid = 1000;
|
uid = 1000;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue