Backup the local pacman database when it changes. https://aur.archlinux.org/packages/pakbak-git/
Please make sure that your system fulfills the prerequisites to work with the AUR.
git clone https://aur.archlinux.org/pakbak-git.git
cd pakbak-git
makepkg -si
(see build and install in the ArchWiki)
After the installation has been finished make sure, that the service is started, when your pacman db changes.
systemctl enable pakbak.path