Creating backup files.
In order to backup the data create dump files from both MySQL and InfluxDB for each restoration point.
MySQL
To create MySQL dump go to AT installation folder\mysql\bin (default path is C:\Program Files (x86)\Algotrader\Algotrader_6.x.x\mysql\bin) and execute following command using terminal (e.g. cmd):
mysqldump.exe -u root -p algotrader --triggers --port=23306 > C:\[path to store the file]\dump_file.sql
When prompted, enter the password to the DB, after that MySQL dump file will be created.
InfluxDB
To dump InfluxDB go to AT installation folder\influxdb (default path is C:\Program Files (x86)\Algotrader\Algotrader_6.x.x\influxdb) and execute following command using terminal (e.g. cmd):
influxd.exe backup -portable -database algotrader -host localhost:8088 C:\[path to store the folder]\tmp\
InfluxDB dump files will be created in the \tmp folder.
Restoring databases using backup files.
MySQL
To load data to a clean MySQL database with a valid AlgoTrader schema (to drop the existing database and create a new with a valid schema use flyway clean migrate as instructed further in this article) go to AT installation folder\mysql\bin (default path is C:\Program Files (x86)\Algotrader\Algotrader_6.x.x\mysql\bin) and execute the following command using terminal (e.g. cmd):
mysql.exe -u root -p algotrader --port=23306 < [path to stored file]
(specify the full path to the file or copy the file to the current folder)
InfluxDB
To restore the InfluxDB database it's necessary to drop the existing one in the first place.
To load data to InfluxDB go to AT installation folder\influxdb (default path is C:\Program Files (x86)\Algotrader\Algotrader_6.x.x\influxdb) and execute the following command using terminal (e.g. cmd):
influxd.exe restore -portable -db algotrader [path to stored directory]
(specify the full path to the folder or copy it to the current folder)
Scheduling periodical backup using task scheduler (Windows)
Windows has a built-in solution for the periodical execution of tasks - task scheduler. One way to perform the above tasks using it is to create batch scripts for each:
AT installation folder\mysql\bin\mysqldump.bat
set "datesuffix=%date:~4,10%"
set "datesuffix=%datesuffix:/=%"
mysqldump.exe -u root -p algotrader --triggers --port=23306 > C:\[path to store file]\dump_file_%datesuffix%.sql
AT installation folder\influxdb\influxdbdump.bat
set "datesuffix=%date:~4,10%"
set "datesuffix=%datesuffix:/=%"
influxd.exe backup -portable -database algotrader -host localhost:8088 [path to store the folder]\tmp_%datesuffix%\
Once the batch files are created you can set up the tasks using the task scheduler.
- Start task scheduler using the start menu in windows.
- Select Action->Create Task...
- In General, the tab select a name for the first task (e.g. "MySQL backup")
- In the Triggers tab select "New trigger..."
- Leave the default value of "On schedule" on top and set the desired frequency and time of process and press OK
- In the Actions tab select "New..."
- Leave the default value of Action as "Start a program" set "Program/script" to the first batch file created earlier and press OK
- Finish creating the task by pressing OK at the bottom of the popup window and repeat the process for the other batch file
Now task scheduler will trigger the backup process every selected amount of time. The backup files (or directories for influx) will be available in locations selected suffixed with the date in format MMDDYYYY.
Comments
0 comments
Please sign in to leave a comment.