Skip to content

Commit

Permalink
paperless: cleanup old backup files
Browse files Browse the repository at this point in the history
  • Loading branch information
paulfantom committed Dec 1, 2024
1 parent 708942e commit 5f09c19
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 10 deletions.
31 changes: 21 additions & 10 deletions apps/paperless/jsonnet/main.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,27 @@ local all = {
spec+: {
template+: {
spec+: {
initContainers: [{
// init container to change permissions on the backup directory to 0777 due to bug in longhorn RWX support
command: ['sh', '-c', 'chmod 0777 /mnt/backups'],
image: 'busybox',
name: 'permissions',
volumeMounts: [{
mountPath: '/mnt/backups',
name: 'backups',
}],
}],
initContainers: [
{
// init container to change permissions on the backup directory to 0777 due to bug in longhorn RWX support
command: ['sh', '-c', 'chmod 0777 /mnt/backups'],
image: 'busybox',
name: 'permissions',
volumeMounts: [{
mountPath: '/mnt/backups',
name: 'backups',
}],
},{
// init container to remove old backups
command: ['sh', '-c', 'find /mnt/backups -mtime +20 -type f -delete'],
image: 'busybox',
name: 'cleanup',
volumeMounts: [{
mountPath: '/mnt/backups',
name: 'backups',
}],
}
],
},
},
},
Expand Down
9 changes: 9 additions & 0 deletions apps/paperless/manifests/web/cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ spec:
volumeMounts:
- mountPath: /mnt/backups
name: backups
- command:
- sh
- -c
- find /mnt/backups -mtime +20 -type f -delete
image: busybox
name: cleanup
volumeMounts:
- mountPath: /mnt/backups
name: backups
restartPolicy: Never
serviceAccountName: paperless
volumes:
Expand Down
18 changes: 18 additions & 0 deletions pod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v1
kind: Pod
metadata:
name: task-pv-pod
namespace: paperless
spec:
volumes:
- name: backups
persistentVolumeClaim:
claimName: backups
containers:
- name: tcpdump
command: ["/bin/bash"]
args: ["-c", "while true; do ping localhost; sleep 60;done"]
image: nicolaka/netshoot
volumeMounts:
- mountPath: "/data"
name: backups

0 comments on commit 5f09c19

Please sign in to comment.