backup module fix, it now supports multiple folders
This commit is contained in:
parent
da94e520ee
commit
cf8a2f0b74
5 changed files with 145 additions and 122 deletions
33
modules/backup/shell-utils.nix
Normal file
33
modules/backup/shell-utils.nix
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
path,
|
||||
config,
|
||||
pkgs,
|
||||
}:
|
||||
pkgs.writeShellApplication {
|
||||
name = "backup-${baseNameOf path}.sh";
|
||||
runtimeInputs = [
|
||||
pkgs.gnutar
|
||||
pkgs.gzip
|
||||
];
|
||||
text = ''
|
||||
#!/bin/bash
|
||||
|
||||
# Archive creation and compression
|
||||
SRC=${path}
|
||||
DST=$(mktemp --suffix=.tar)
|
||||
echo "Archiving and compressing $SRC to $DST."
|
||||
${config.compression.command}
|
||||
|
||||
# Archive encryption (optionnal)
|
||||
SRC=$DST
|
||||
DST=$(mktemp --suffix=.tar.encrypted)
|
||||
echo "Encyphering $SRC to $DST."
|
||||
${config.encryption.command}
|
||||
|
||||
# Archive salvation
|
||||
SRC=$DST
|
||||
DST="${config.dest}/${baseNameOf path}.tar.enc"
|
||||
echo "Saving $SRC to $DST."
|
||||
${config.salvation.command}
|
||||
'';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue