I want to use
rsync to backup databases from my webserver.
I created a cronjob on the webserver that creates a
mysqldump of the database and names it with the current date in the beginning every night. Files older than 30 days will be deleted.
Now I want to backup only the databasefile of the current date to my NAS via a cronjob.
How can I only include that one file? Or vise versa, how can I exclude everything except that one file?
My code for
rsync is the following:
rsync -avz -h -c --include="*$(date +%Y-%m-%d)*" -e "ssh -p $PORT" $USER@$SERVER:$SQL_SOURCE $SQL_TARGET --delete
The filename for today thats on the webserver would be
But also every other file like
2021-06-29_databasename.sql gets synced.