Simple backup of maildir folder

Francis Augusto Medeiros-Logeay r_f at med-lo.eu
Sun May 31 21:05:00 EEST 2020



> 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 


More information about the dovecot mailing list