A Common Lisp script which runs in background, creates a zip file of the ~/Maildir/ folder and copies the zip file to ~/Documents/ folder so that nextcloud client is able to sync it to the nextcloud server instance.
Repository: https://code.metalisp.dev/marcuskammer/maildir-backup
(defun run-mbsync ()
"Runs mbsync to synchronize mail directories."
(with-open-file (out "/tmp/mbsync.log" :direction :output :if-exists :supersede)
(uiop:run-program "mbsync -a" :output out :error-output out)))
(defun create-zip (maildir backup-file)
"Creates a zip archive of the specified Maildir."
(with-open-file (out "/tmp/zip.log" :direction :output :if-exists :supersede)
(uiop:run-program (format nil "zip -r /tmp/~A ~A" backup-file maildir)
:output out :error-output out)))
(defun move-zip (backup-file backup-dir)
"Moves the zip archive to the specified backup directory."
(let ((source (merge-pathnames backup-file #P"/tmp/"))
(destination (merge-pathnames backup-file backup-dir)))
(uiop:copy-file source destination)
(delete-file source)))