At work, I’ve fallen in love with Git for our revision software. A co-worker told me that he uses Git to automatically backup his entire home directory on his computer, so I figured I could do something similar with the VPS that hosts this website.

There are two things required to make this work: Git, and a destination server to push your backup to.

The script I’m using is copied below (password redacted for security).

All in all, pretty basic as far as things go. Dump the entire MySQL/MariaDB database, copy all the bare files from the /var/www directory, and then commit them to git. The other advantage of this is that it’s dead simple to restore a backup from any previous date. The nice advantage of using git is that it’s entirely OS agnostic, so I can restore the contents from one system to the other with minimal difficulties.