Each online MySQL Cluster backup receives a unique identification number. This is to ensure that there is a history of activities in the backup directory. However, this can causes problems. For example, if a system restarts, this ID counter is reset and starts again at number 1, causing problems if you didn’t move earlier backups. This post will discuss how to generate unique backup ids.
The best method is after each online backup operation to move the created backup directory to another location (e.g. a file server). This will ensure that there can never be a problem with duplicate backup IDs on the data nodes themselves. Additionally, you can generate your own backup IDs and pass them to the START BACKUP statement using the ndb_mgm client tool. As of MySQL Cluster versions 6.2.17, 6.3.23, and 7.0.3, this ID has an upper limit of 4294967296 (232). Earlier versions only support a maximum of 2147483648 (231).
One example of how to generate your own backup ID is to use Unix or POSIX time. The advantage of this is that it is already a 32-bit number and each time you run START BACKUP it will be the current time, which is unique unless you tamper with the system clock. You would enter something like the following from the command-line:
$ TS=$(date +%s) && ndb_mgm -e "START BACKUP ${TS}" Connected to Management Server at: localhost:1186 Waiting for completed, this may take several minutes Node 1: Backup 1455575258 started from node 49 Node 1: Backup 1455575258 started from node 49 completed StartGCP: 2596 StopGCP: 2599 #Records: 7378 #LogRecords: 0 Data: 501128 bytes Log: 0 bytes
Another example would be to use the actual date and hour a backup is made. The advantage of this is that it’s easier to read and one can see directly from which day the backup was made. The following example, however, will only work once per hour—it’s entered from the command-line, as well:
$ TS=$(date +%Y%m%d%H) && ndb_mgm -e "START BACKUP ${TS}" Connected to Management Server at: localhost:1186 Waiting for completed, this may take several minutes Node 1: Backup 2016021609 started from node 49 Node 1: Backup 2016021609 started from node 49 completed StartGCP: 2665 StopGCP: 2668 #Records: 7378 #LogRecords: 0 Data: 501128 bytes Log: 0 bytes
There are many possible ways to generate backup IDs and not be restricted to timestamps. You could generate a counter which is stored in a central database running on your backup server. How you generate an ID is up to you.