Requirements:
- daily jira & confluence mysql database backup;
- daily backup of jira & confluence attachments directory;
- backups archiving;
- deleting the old backups (more than 14 days);
Please note that I had a requirements for windows machine, and I understand that linux provides more scalabale and elegant way to do that. That is a basic script that can be used as a working solution, any system administrator can do that without my help :)
At first, let’s define the variables:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
Every backup should have a unique name. So I’m proposing to use year, month, day and time interval in that name.
1 2 3 4 |
|
Please feel free to name it as you wish. In my case the name pattern is : [db name].YYYY-MM-DD_tt
date_folder variable is for a directory. I’d like to have a folder with the name like YYYY-MM-DD that will be created on a daily basis and put the proper backups in it.
Thus, let’s create the directory if it is not created yet:
1 2 3 |
|
After that, the regular backup process with the help of mysqldump and archiving with 7zip. After that we can clean the archived file (as we have archive).
1 2 3 |
|
Do not forget to archive our attachments:
1
|
|
And what we still have to do is to delete the old backups:
1
|
|
That’s it! Now we can use that batch script in Windows Task Scheduler and scheduled it on a daily basis.
P.S. If the task is not working, please check: - Task should be launched even when the user is logged off - The user that is launching that task has the permissions to do that (r/w permissions) - Task should be launched from the directory where the script is located (optional parameter, but it is required to set the proper path)
P.P.S. If you would like to download script, please find it here: download