Skip to content

Commit 88a7644

Browse files
committed
add usage directions
1 parent f1490ed commit 88a7644

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

sql/USAGE.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,49 @@
11
# Using the SQL queries
2+
3+
The safest way to run these queries is by using the backup created by [backup-utils](https://github.com/github/backup-utils) loaded into another database server. This database can be quite large and GitHub Enterprise Server can be sensitive to I/O intensive operations that aren't part of anticipated load.
4+
5+
:warning: This database contains sensitive information. Please treat it appropriately within your company / network!
6+
7+
A simple way to do this would be to install a MySQL 5.7 server on the VM receiving the backups and load it automatically. You can then connect to in using `root` with no password, or whatever you set up for authentication. What this looks like in practice would be similar to this shell script:
8+
9+
```shell
10+
# Stop MySQL
11+
sudo systemctl stop mysqld.service
12+
13+
# Unzip the most current backup
14+
gunzip -c /data/current/mysql.sql.gz > /data/mysql.tar
15+
16+
# Untar the current backup
17+
tar xf /data/mysql.tar --directory=/home/github/restore-job/
18+
19+
# Remove the temporary tarball
20+
rm /data/mysql.tar
21+
22+
# Clear the data directory before restoring
23+
sudo rm -rf /var/lib/mysql-data/*
24+
25+
# Run the Percona backup restore
26+
cd /home/github/restore-job && sudo innobackupex --defaults-file=backup-my.cnf --copy-back --datadir=/var/lib/mysql-data .
27+
28+
# Restore the innodb buffer pool
29+
sudo cp -n /var/lib/mysql/ib_buffer_pool /var/lib/mysql-data/
30+
31+
# Restore the innodb data
32+
sudo cp -n /var/lib/mysql/ibdata1 /var/lib/mysql-data/
33+
34+
# Restore the first and second logs
35+
sudo cp -n /var/lib/mysql/ib_logfile0 /var/lib/mysql-data/
36+
sudo cp -n /var/lib/mysql/ib_logfile1 /var/lib/mysql-data/
37+
38+
# Reset ownership
39+
sudo chown -R mysql:mysql /var/lib/mysql-data
40+
41+
# Restore SELinux contexts (if applicable)
42+
sudo restorecon -R /var/lib/mysql-data
43+
44+
# Start MySQL
45+
sudo systemctl start mysqld.service
46+
47+
# Clear the working directory to save some disk space
48+
rm -rf /home/github/restore-job/*
49+
```

0 commit comments

Comments
 (0)