On 29 May 2020, at 23:49, Admin Beckspaced <admin at beckspaced.com> wrote:> I also have maildir as mailbox format and use the following script to do daily backups > > https://github.com/tachtler/dovecot-backupA couple of notes on this quite useful script: My mktemp does not support -p (FreeBSD 12.1) is I had to change the script to: DIR_TEMP=$($MKTEMP_COMMAND -d $TMP_FOLDER -t $SCRIPT_NAME) Which gives a temp folder along the lines of /tmp/dovecot_backup.IiZ00GyZ I also changed the various date strings to date -Iseconds and date -R for the mail handling since the format in the script is not to spec, using Fri, 29 May 2020 23:49:31 (-0600) Instead of the -R, --rfc-email output date and time in RFC 5322 format. Example: Mon, 14 2006 02:34:56 -0600 -- FRIDAYS ARE NOT "PANTS OPTIONAL" Bart chalkboard Ep. AABF23
Sent with ProtonMail Secure Email. ??????? Original Message ??????? On Sunday, 31 May 2020 09:35, @lbutlr <kremels at kreme.com> wrote:> > A couple of notes on this quite useful script: > > My mktemp does not support -p (FreeBSD 12.1) is I had to change the script to: >In my scripts I tend to create a tempdir and then tempfiles within that. It makes the cleanup routine neater, e.g. at the top of my scripts : TEMP_DIR=$(mktemp -qd || { doLog "Failed to make temp dir !"; exit 1; }) rmTmpFiles() { rm -rf "${TEMP_DIR}"; } createTempFile() { local MYTEMP=$(mktemp -qp "${TEMP_DIR}" || doLog "Failed to create temp file"; exit 1); echo $MYTEMP; } Also my backup scripts have locking procedures built-in so as to avoid race conditions.
> On 31 May 2020, at 11:13, Laura Smith <n5d9xq3ti233xiyif2vp at protonmail.ch> wrote: > > ? > > > Sent with ProtonMail Secure Email. > > ??????? Original Message ??????? >> On Sunday, 31 May 2020 09:35, @lbutlr <kremels at kreme.com> wrote: >> >> >> >> A couple of notes on this quite useful script: >> >> My mktemp does not support -p (FreeBSD 12.1) is I had to change the script to: >> > > > In my scripts I tend to create a tempdir and then tempfiles within that. It makes the cleanup routine neater, e.g. at the top of my scripts : > > TEMP_DIR=$(mktemp -qd || { doLog "Failed to make temp dir !"; exit 1; }) > rmTmpFiles() { rm -rf "${TEMP_DIR}"; } > createTempFile() { local MYTEMP=$(mktemp -qp "${TEMP_DIR}" || doLog "Failed to create temp file"; exit 1); echo $MYTEMP; } >I don?t think I need to clean up, and my ?temp_dir? will end up being permanent, as to make doveadm backup snappier I will simply maintain the directory there and use crown jobs to update the dir.> Also my backup scripts have locking procedures built-in so as to avoid race conditions.Also not sure if that?s needed when using doveadm backup, as it takes care of the potential race conditions. So the idea is to use doveadm to a local folder, then rsync it to a remote server where snapshots can be easily created. It annoys me have to do the doveadm to the local server - seems like a waste of disk space, but since maildirlock is not working and since doveadm backup to a remote server requires a bit more work to, well, to work, so I guess this is a simple and quick solution. Best, Francis
On 31 May 2020, at 03:11, Laura Smith <n5d9xq3ti233xiyif2vp at protonmail.ch> wrote:> On Sunday, 31 May 2020 09:35, @lbutlr <kremels at kreme.com> wrote: >> A couple of notes on this quite useful script: >> >> My mktemp does not support -p (FreeBSD 12.1) is I had to change the script to: > > > In my scripts I tend to create a tempdir and then tempfiles within that. It makes the cleanup routine neater, e.g. at the top of my scripts :The script linked in my message has most, if not all the features you mention below. I was simply pointing out for anyone who followed this that FreeBSD's mktempo does not support the -p flag and the changes I made to the line that created the temp directory in order to work.> TEMP_DIR=$(mktemp -qd || { doLog "Failed to make temp dir !"; exit 1; }) > rmTmpFiles() { rm -rf "${TEMP_DIR}"; } > createTempFile() { local MYTEMP=$(mktemp -qp "${TEMP_DIR}" || doLog "Failed to create temp file"; exit 1); echo $MYTEMP; } > > Also my backup scripts have locking procedures built-in so as to avoid race conditions.-- "Are you pondering what I'm pondering?" "Well, I think so, Brain, but I can't memorize a whole opera in Yiddish."
On Sun, 31 May 2020, Laura Smith wrote:>> A couple of notes on this quite useful script: >> >> My mktemp does not support -p (FreeBSD 12.1) is I had to change the script to: > > In my scripts I tend to create a tempdir and then tempfiles within that. It makes the cleanup routine neater, e.g. at the top of my scripts : > > TEMP_DIR=$(mktemp -qd || { doLog "Failed to make temp dir !"; exit 1; }) > rmTmpFiles() { rm -rf "${TEMP_DIR}"; } > createTempFile() { local MYTEMP=$(mktemp -qp "${TEMP_DIR}" || doLog "Failed to create temp file"; exit 1); echo $MYTEMP; } > > Also my backup scripts have locking procedures built-in so as to avoid race conditions.You might also want a trap handler that does a cleanup in case something goes sideways in the middle of processing e.g. trap rmTmpFiles 0 Joseph Tam <jtam.home at gmail.com>