Rsync and cron scrip as for backup

I have used rsync to move files between servers but what I want to do now is out of my knowledge.

I have to ubuntu servers, one is used for websites and the other one mostly to store backups.

One website is a nextcloud server. It contains a lot of images, over 20000, meaning its a lot of space. Every day new images are added. My idea was to use rsync to to backup the website by sync the image folers every night. That should save a lot of time not sending the whole 56 Gb of pictures every time, but only add the new ones.
But the database cant as I understand it not be synced that way, it must be either sent as a sql dump or replicated.
So 2 questions.
How do this best with the db
And also, can this be setup as a script and run using cron

Hope its understandable, english is not my native languiage

Depends how your target server is configured. If it’s a mirror, you can just dump and restore if the DB is small enough and not have to think about it. It does transfer a lot of data each time, that you might not need to transfer.

Replication (active + standby clusters) are more efficient, because you only do log shipping (the transaction logs of the DB), which get applied on the target DB. But it’s a way more complex setup and I advise against it, unless you’re looking for a really high availability setup (if you’re in a corporate environment, then only go for it if people can’t work if they lose access to the main nextcloud instance - the money that the company spends when they sit idly is going to cost a lot more than the time 1 or 2 people will spend setting up, maintaining and fixing the DB HA cluster).

As a reminder, replication is not backup. Make sure you still run dumps or do offline backups.

Speaking of which, there is another option. If you can don’t care about the DB going down every night or so, then shut down the DB on both servers, rsync the file system, start the DBs. It’s basically an offline backup and it does work, but make sure you also save the transaction logs, just in case.

IMO, the most hassle-free experience is doing dumps, restoring them and keeping a few around just in case.

There is a technique to use rsync and hard links to make incremental snapshot backups. I think this is the original article describing the method

Rsnapshot is a utility based on this method. For file backups, you might also consider a backup program like Duplicati or Restic.