This is an example crontab for “rolling” daily and monthly backups. Typically, the “/from/location/” will actually be a daily backup that is rsynced from another physical location (I like to have backups across multiple physical locations covering daily going back one week, and monthly going back one year).
First make sure all of your back “to location” directories exist.
mkdir -p /to/location/backup/daily/ && cd /to/location/backup/daily/ mkdir -p Sunday Monday Tuesday Wednesday Thursday Friday Saturday mkdir -p /to/location/backup/monthly/ && cd /to/location/backup/monthly/ mkdir -p January February March April May June July August September October November December
Here’s what the crontab entries might look like.
@daily /bin/rsync -axv --delete/from/location/ /to/location/backup/daily/$(date +\%A)/ @monthly /bin/rsync -axv --delete /from/location/to/location/backup/monthly/$(date +\%B)/