Backup Scripts

From Executive Jeweller
Jump to navigation Jump to search

If you do not already have a backup system in place, it is recommend to prepare a basic rolling backup script. The minimum requirements for this are simply your server's hard drive, but it's recommended to have an external hard drive so that files can be redundantly backed up in case of failure in the main hard drive.

The scripts below are all batch files, which can then be triggered by Windows Task Scheduler. To create a batch file, simply open Notepad, enter the script text, and when saving it, choose file type 'All' and then name the file with a .bat extension (such as dailybackup-execdata.bat). These scripts can be extended to include image folders in monthly backups, front end and setup installations, or many other combinations, but just the basics are outlined below. For more examples of creating backup scripts and automating them with Task Scheduler, see this online tutorial.

Daily Script

{{{1}}}


@for /F "tokens=1 delims=, " %%i In ('powershell date') do set dow=%%i xcopy c:\executive\server\executivedata.mdb c:\executive\server\backups\%dow:~0,3%\* /Y

The above script will copy your ExecutiveData.mdb file and place it in a folder based on the day of the week. So if it's ran on a Friday, it would backup the file to 'backups\fri\executivedata.mdb'.

Monthly Script

xcopy c:\executive\server\executivedata.mdb c:\executive\server\backups\Monthly\%date:~10,4%-%date:~4,2%\* /Y


The above script will copy your ExecutiveData.mdb file and place it in a folder based on the current year and month. So if it's ran on Oct 28, 2012, it would backup the file to 'backups\Monthly\2012-10\executivedata.mdb'.

Copy to External Drive

xcopy c:\executive\server\backups\* x:\backups\executive\server\backups\* /Y /Q /S


The above script will copy the contents of your local backups folder, and create a backup structure on a different drive. In this example the drive is X:, which represents an external hard drive.

Task Scheduler

To run Windows Task Scheduler, go to Control Panel-Administrative Tools-Task Scheduler. From here, choose 'Create Basic Task'
Task0.png

Enter the name of your task, and a brief description.
Task1.png

Choose the frequency of the task execution. Daily and Monthly are common backup schedules, and each allow selection of various criteria.
Task2.png

Generally it's advised to schedule these tasks to run overnight, so that it doesn't interfere with daily usage of the workstation and files. For monthly jobs, choosing either the first or last day of the month is common.

Daily Criteria
Task3.png

Monthly Criteria
Task7.png

Choose to start a program as the main task to perform
Task4.png

Browse and select the script that you want to schedule
Task5.png

View the final summary and ensure everything is correct. Go back and make changes if necessary, or hit Finish to complete this task. You can then add more tasks as necessary for additional scripts.
Task6.png

When you are finished and backups have been running for some time, your backup folder will look similar to this (it may have an 'externaldrivebackup.bat' file if you use that script as well).
Backups folder.png