content_image/786144.jpg
If your replica is replicating LOAD DATA  statements, you should also back up any SQL_LOAD-*  files that exist in the directory that the replica uses for this purpose. The replica needs these files to resume replication of any interrupted LOAD DATA  operations. The location of this directory is the value of the slave_load_tmpdir  system variable. If the server was not started with that variable set, the directory location is the value of the tmpdir  system variable. 

## 17.4.1.3 Backing Up a Source or Replica by Making It Read Only 

It is possible to back up either source or replica servers in a replication setup by acquiring a global read lock and manipulating the read_only  system variable to change the read-only state of the server to be backed up: 

1. Make the server read-only, so that it processes only retrievals and blocks updates. 

2. Perform the backup. 

3. Change the server back to its normal read/write state. 

<img src='content_image/786144.jpg'>

## Note 

The instructions in this section place the server to be backed up in a state that is safe for backup methods that get the data from the server, such as mysqldump (see Section 4.5.4, “mysqldump — A Database Backup Program” ). You should not attempt to use these instructions to make a binary backup by copying files directly because the server may still have modified data cached in memory and not flushed to disk. 

The following instructions describe how to do this for a source and for a replica. For both scenarios discussed here, suppose that you have the following replication setup: 

•A source server S1 

•A replica server R1 that has S1 as its source 

•A client C1 connected to S1 

•A client C2 connected to R1 

In either scenario, the statements to acquire the global read lock and manipulate the read_only  variable are performed on the server to be backed up and do not propagate to any replicas of that server. 

## Scenario 1: Backup with a Read-Only Source 

Put the source S1 in a read-only state by executing these statements on it: 

mysql> FLUSH TABLES WITH READ LOCK; mysql> SET GLOBAL read_only = ON; 

While S1 is in a read-only state, the following properties are true: 

•Requests for updates sent by C1 to S1 block because the server is in read-only mode. 

•Requests for query results sent by C1 to S1 succeed. 

•Making a backup on S1 is safe. 

•Making a backup on R1 is not safe. This server is still running, and might be processing the binary log or update requests coming from client C2. 

