undo you can check
:h undo-persistence topic:
5. Undo persistence *undo-persistence* *persistent-undo*
When unloading a buffer Vim normally destroys the tree of undos created for
that buffer. By setting the 'undofile' option, Vim will automatically save
your undo history when you write a file and restore undo history when you edit
the file again.
The 'undofile' option is checked after writing a file, before the BufWritePost
autocommands. If you want to control what files to write undo information
for, you can use a BufWritePre autocommand: >
au BufWritePre /tmp/* setlocal noundofile
I am not so sure about
backup, as the option is global and you can't easily set it per buffer, but there is
backupskip option you can try to use:
'backupskip' 'bsk' string (default: "$TMPDIR/*,$TMP/*,$TEMP/*"
A list of file patterns. When one of the patterns matches with the
name of the file which is written, no backup file is created. Both
the specified file name and the full path name of the file are used.
The pattern is used like with |:autocmd|, see |autocmd-patterns|.
Watch out for special characters, see |option-backslash|.
When $TMPDIR, $TMP or $TEMP is not defined, it is not used for the
default value. "/tmp/*" is only used for Unix.