feat: prune old cld backups after sync
This commit is contained in:
@@ -27,6 +27,7 @@ in {
|
||||
|
||||
path = with pkgs; [
|
||||
coreutils
|
||||
findutils
|
||||
openssh
|
||||
rsync
|
||||
util-linux
|
||||
@@ -53,7 +54,9 @@ in {
|
||||
exit 1
|
||||
fi
|
||||
|
||||
flock -n "$lock_file" \
|
||||
(
|
||||
flock -n 9
|
||||
|
||||
rsync \
|
||||
-aH \
|
||||
--no-owner \
|
||||
@@ -69,6 +72,13 @@ in {
|
||||
-e "ssh -i ${sshKey} -p ${targetPort} -o IdentitiesOnly=yes -o BatchMode=yes -o StrictHostKeyChecking=accept-new -o UserKnownHostsFile=/var/lib/${serviceName}/known_hosts" \
|
||||
${sourceDir} \
|
||||
${targetUser}@${targetHost}:${targetDir}
|
||||
|
||||
echo "Removing /var/backup files older than 7 days"
|
||||
find ${sourceDir} -type f -mtime +7 -print -delete
|
||||
|
||||
echo "Removing empty directories under /var/backup"
|
||||
find ${sourceDir} -mindepth 1 -depth -type d -empty -print -delete
|
||||
) 9>"$lock_file"
|
||||
'';
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user