Creating backups of server data in Dropbox.

Recently faced with the task of creating server data backups on my vps. Various websites are hosted on it. My personal ones are built on more or less reasonable technologies/engines, so all the code is in version control system. For such sites, only backup of the database and uploaded data is needed. Some third-party sites are built on WordPress, so the source code also needs to be backed up.

So, the task is as follows: with a certain frequency, databases and the contents of certain directories need to be backed up. Backups should be kept for a specific period of time to save space.