Question
How to back-up the Work-IT database automatically each day weekly or for a couple of days weekly?
Answer
Sometimes it is more secure for our valuable database to have weekly 7 backups (or less) instead of one backup file that will be overwritten every day!
which could lead to the loss of the database if the current backup file didn't save directly in a different place and is not overwritten with the backup of the crashed database.
So with the advanced backup system, you will have the choice to restore your database from any 7 (or less) backup files that you have from the previous week.
Before we start explaining the backup options in this batch files let's make sure that we create those 3 folders in the drive where we want to save the backup files (for example c: drive)
1- C:\Work-IT_Backup
2- C:\Work-IT_Extra_Backup
then create those 7 folders in this folder (All weekdays)
- Monday
- Tuesday
- Wednesday
- Thursday
- Friday
- Saturday
- Sunday
3- C:\Work-IT_Extra_Backup_temp
Then unzip the two files( backupdb.bat + backupdb.sql )in the attached zip file to the folder C:\Work-IT_Backup
Actually here we will use another batch file than the one in the article:
EN - Backup Work-IT database
This advanced batch file (backupdb.bat), you can find in the attached zip file, the following screenshot gives an overview of the commands in this advanced batch file:
As you can see, the batch file will make a backup file first in the folder C:\Work-IT_Backup, then he will zip the backup file and move it to the right weekday folder according to the day of running the batch file.
And after the first week, you will have extra backup files for each day in the week, each one in its own folder in the path C:\Work-IT_Extra_Backup.
So that you can go back and restore the right good backup file from a day of the previous week where you think that the database was successful.
As you can see from the screenshot above, you can let the system make extra backup files for only two days (for example on Monday and Thursday) instead of all 7 days of the week, here we need to make the right modification in the batch file.
With this modification, you need less saving space in the drive than if you make 7 backup files on all weekdays, so as you can see we can customize this batch file according to your needs.
After making the right changes in the batch file, you can use " Task scheduler " in Windows to let him run the batch file daily in a cerian time by following these steps:
1. Open Windows Task Scheduler (via the control panel, system administration, task scheduler)
2. From the right side menu "Actions" click Create task...
3. On the "General" tab, choose "Run whether the user is logged on or not" and also check the option "Run with highest privileges"
4. On tab "Triggers" enter the following:
-Click "New"
- Choose "Daily"
- Set the time when the backup should be made, then click "OK"
5. On tab "Actions" follow these steps:
- Click New.
- Make sure that you choose "Start a program"
- Choose in "Program" the bat file "backupdb.bat", with his path.
- Click "OK"
6. On tab "Settings":
- Activate the option "Stop the task if it runs longer than:", and set it to "4 hours"
- Click "OK"
Note: You will be asked to log in with windows login credentials. you can then log in with the current windows user, or choose another User
Finally:
You must always keep controlling whether the batch file runs properly or not and whether the Task scheduler runs this batch file properly or not.
Please contact our Work-IT support team to help you set up this advanced backup system with the modifications that suit your needs.