Deployment and Maintenance / Backup and Migration
This article mainly describes how to back up and migrate DataFlux Func data.
1. Database Backup
DataFlux Func automatically backs up the database to .sql files on a regular basis and stores them in the DataFlux Func database backup directory.
This feature backs up the database via mysqldump. The MySQL user connecting to the database needs sufficient permissions to back up properly, including:
SELECTRELOADLOCK TABLESREPLICATION CLIENTSHOW VIEWPROCESS
The automatic backup includes:
- The complete database table structure
- All data except logs and operation records
By default, database backup files are saved in the following locations:
| Environment | Location |
|---|---|
| Inside container | /data/sqldump/ |
| On host machine | {installation directory}/data/sqldump/ |
By default, the database backup is performed once every hour on the hour, and up to 7 days (168 files in total) are retained. The file naming convention is as follows:
| Text Only | |
|---|---|
1 | |
2. Export / Import Database
In addition to the regular database backup built into DataFlux Func, you can also use mysqldump directly to export and import data.
2.1 Export Data
The reference command for the export operation is as follows:
| Bash | |
|---|---|
1 | |
2.2 Import Data
The reference command for the import operation is as follows:
| Bash | |
|---|---|
1 | |
3. Migrate Database
If the system has passed the initial standalone verification stage after installation, and you need to switch the database to an external database (such as Alibaba Cloud RDS, Redis), you can follow the steps below:
When using an external database, make sure the MySQL version is 5.7 or above, and the Redis version is 5.0 or above
DataFlux Func does not support cluster-deployed Redis
3.1 Confirm Environment
Create a database in the external database instance and ensure the following configuration items:
innodb-large-prefix=oncharacter-set-server=utf8mb4collation-server=utf8mb4_unicode_ci
3.2 Import Data
According to the "Database Backup" section above, find the most recent MySQL database backup file and import it into the external database.
3.3 Modify DataFlux Func Configuration
Locate the DataFlux Func configuration user-config.yaml, and add / modify the following fields according to the actual situation:
| YAML | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 | |
3.4 Modify Docker Stack Configuration
Locate the Docker Stack configuration docker-stack.yaml, and remove (comment out) the MySQL and Redis related sections.
3.5 Restart DataFlux Func
According to Deployment and Maintenance / Upgrade and Restart, restart the entire DataFlux Func.
4. Change Installation Directory
In some cases, the disk where DataFlux Func was originally installed may run out of capacity, and you need to change the installation directory to a new disk with larger capacity.
In this case, you can follow the steps below to change the installation directory.
4.1 Shut Down DataFlux Func
- Use the
docker stack rm dataflux-funccommand to shut down DataFlux Func (this step may take some time) - Use
docker psto confirm that all containers have exited - Use the
cp {installation directory} {new installation directory}command to copy the entire DataFlux Func installation directory to the new location. - Open
/etc/dataflux-funcand change the installation directory recorded therein to the new installation directory. - Modify the Docker Stack configuration
Locate the Docker Stack configuration docker-stack.yaml, and change all volumes entries that involve the installation directory to the new installation directory, for example:
| Diff | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | |
- Use the
docker stack deploy dataflux-func -c {installation directory}/docker-stack.yaml --resolve-image nevercommand to restart all services
Since the image files in the installation package have already been imported locally, adding the --resolve-image never parameter can prevent Docker from performing unnecessary image checks when starting containers