Linux shell to auto backup directories and prune timed backups?

Wondering if anyone who runs their own dedicated server here could lend a hand. Basically just trying to put together a sh file to backup my server directory at a time every night and prune week old backup?

A quick command to back up a folder to another name with the current date:

cp -r /path/to/server /path/to/backup-`date -Idate`/

It doesn’t delete old folders, but it’s a start.

I recommend using rSnapshot, it can be used to sync directories to another machine/drive, and can be configured to keep X of these syncs. It uses hardlinks to deduplicate backups, so therefore even 10 weekly backup take up just around 120% of the original files (and not a full 10x).

Let me know if you need help configuring it.