------ EDIT ------
Sorry, I think I've mistaken the functionality of BackupDir... maybe what you need it's to call copy on BufWinLeave (?):
autocmd! BufWinLeave * :!cp % %.bak
Re-Edit As @Rich has suggested in comments, it seems easier to use :w instead of :!cp. Also the SwitchToNextBuffer() function here could be needed to iterate over all buffers.
------ original answer ------
(Disclaimer: I'm a ultra-noob, but) I looked for "vim manual backup" (found this BackupDir() function) and "vim on quit event" (found this) so maybe something like that would work (I didn't try):
function! BackupDir()
if has('win32') || has('win64')
let l:backupdir=$VIM.'/backup/'.
\substitute(expand('%:p:h'), '\:', '~', '')
else
let l:backupdir=$HOME.'/.vim/backup/'.
\substitute(expand('%:p:h'), '^'.$HOME, '~', '')
endif
if !isdirectory(l:backupdir)
call mkdir(l:backupdir, 'p', 0700)
endif
let &backupdir=l:backupdir
let &backupext=strftime('~%Y-%m-%d_%H-%M-%S~')
endfunction
autocmd! BufWinLeave * call BackupDir()