A Restore Record of OpenProject

Posted by holowugz on Wed, 28 Aug 2019 17:20:39 +0200

A Restore Record of OpenProject

There are problems in the use of OpenProject. The function in a task can not be used. After negotiation, users are ready to revert to the historical version.

I. Prerequisites:

OpenProject has backup files. OpenProject has its own backup command (open project run backup), and the backup files are located in the / var / db / open project / backup directory. Among them:

mysql-dump-20190521032002.sql.gz is the database dump
 conf-20190521032002.tar.gz is a variety of configuration files, including database connections, services and other information
 attachments-20190521032002.tar.gz for backup of all relevant attachment files

II. REDUCTION PROCESS

2.1. Shut down Services

Close the open project service and command system CTL stop open project.

Note: Closing the openproject service shuts down a series of Openproject-related services

2.2. Data recovery

2.2.1. Restore MySQL data

Use the command "zcat mysql-dump-20190521032002.sql.gz | mysql-u open project-h 127.0.0.1-p", then enter the password of MySQL database user openproject and execute the recovery command.

zcat mysql-dump-20190521032002.sql.gz | mysql -u openproject -h 127.0.0.1 -p

zcatYou can view the contents of the compressed package without decompressing the compressed file

| Representative Pipeline

"mysql -u openproject -h 127.0.0.1 -p",Use openproject User Connection 127.0.0.1 In the host mysql Database, openproject The user's password can be queried in the backup file, in this case“ conf-20190521032002.tar.gz"Medium database Documentation.


‚Äč

2.2.2. Recovery configuration file

Unzip the contents of the archived configuration file (conf-20190521032002.tar.gz) and copy them to the directory of "/etc/openproject/conf.d/" and overwrite the original file.

2.2.3. Restore the backup of attachment files

Unzip the contents of the archive file (attachments-20190521032002.tar.gz) and copy them to the directory of'/ var/db/openproject/files/'to overwrite the original contents.

Note: This is an attachment uploaded from each Project or Task of Openproject. According to the actual situation, it is free to choose whether to restore or not.

2.3. Start-up Services

Start the open project service with the "system CTL start open project" command

III. Operational Procedure and Command Recording

The following is the record and description of the commands executed at different stages of the recovery process.

3.1. Preparing backup files

# View the current path
[root@localhost backup]# pwd
/var/db/openproject/backup
# Create / home/tmp folder
[root@localhost backup]# mkdir /home/tmp
# Copy backup files to newly created folders
[root@localhost backup]# cp mysql-dump-20190521032002.sql.gz /home/tmp/
[root@localhost backup]# cp conf-20190521032002.tar.gz /home/tmp/
[root@localhost backup]# cp attachments-20190521032002.tar.gz /home/tmp/
[root@localhost backup]# cp svn-repositories-20190521032002.tar.gz git-repositories-20190521032002.tar.gz /home/tmp/
# Switch to the newly created folder
[root@localhost backup]# cd /home/tmp/
# List folders under folders
[root@localhost tmp]# ls -lha
total 168M
drwxr-xr-x  2 root root  213 May 24 10:34 .
drwxr-xr-x. 6 root root  104 May 24 10:33 ..
-rw-r-----  1 root root 167M May 24 10:34 attachments-20190521032002.tar.gz
-rw-r-----  1 root root  773 May 24 10:34 conf-20190521032002.tar.gz
-rw-r-----  1 root root  124 May 24 10:34 git-repositories-20190521032002.tar.gz
-rw-r-----  1 root root 253K May 24 10:33 mysql-dump-20190521032002.sql.gz
-rw-r-----  1 root root  110 May 24 10:34 svn-repositories-20190521032002.tar.gz

3.2. Discontinuation of services

# Close the openproject service
[root@localhost tmp]# systemctl stop openproject
[root@localhost tmp]# 

3.3. Data recovery

# Query files under files
[root@localhost tmp]# ls
attachments-20190521032002.tar.gz       mysql-dump-20190521032002.sql.gz
conf-20190521032002.tar .gz                svn-repositories-20190521032002.tar.gz
git-repositories-20190521032002.tar.gz
# Restoring database data
[root@localhost tmp]# zcat mysql-dump-20190521032002.sql.gz | mysql -u openproject -h 127.0.0.1 -p openproject
Enter password: 
[root@localhost tmp]#
# Unzip the configuration file
[root@localhost tmp]# gunzip conf-20190521032002.tar.gz 
[root@localhost tmp]# tar -xvf conf-20190521032002.tar 
./
./other
./database
./server
./memcached
# After viewing and unzipping the configuration file, the contents of the folder
[root@localhost tmp]# ls
attachments-20190521032002.tar.gz       mysql-dump-20190521032002.sql.gz
conf-20190521032002.tar                 other
database                                server
git-repositories-20190521032002.tar.gz  svn-repositories-20190521032002.tar.gz
memcached
# Copy the decompressed configuration file to overwrite the configuration file in Openproject system
[root@localhost tmp]# cp database memcached other server /etc/openproject/conf.d/
cp: overwrite '/etc/openproject/conf.d/database'? y
cp: overwrite '/etc/openproject/conf.d/memcached'? y
cp: overwrite '/etc/openproject/conf.d/other'? y
cp: overwrite '/etc/openproject/conf.d/server'? y
# In this case, the time needed to recover and the current time did not change, but failed to recover.

3.4. Start-up Services

Start the open project service with system CTL start open project.

# Start the openproject service
[root@localhost tmp]# systemctl start openproject
# openproject is also a binary command, which is used as follows:
[root@localhost ~]# openproject 
Usage:
  openproject run COMMAND [options]
  openproject scale TYPE=NUM
  openproject logs [--tail|-n NUMBER]
  openproject config:get VAR
  openproject config:set VAR=VALUE
  openproject configure
  openproject reconfigure
  openproject restart

Details:
  openproject configure [-f FILE|-]
    * If using an installer:
      This command will launch the installer wizard.
      You can pass the installer seed file as argument or on STDIN.
   * Without installer:
      This will execute the configure script at /opt/openproject/packaging/scripts/configure (if any).
      A file containing environment variables can be given as argument or on STDIN (-f -), and will be saved in the /etc/openproject/conf.d folder.

  openproject reconfigure
    This command allows to reconfigure the application. Only useful if using an installer.

  openproject restart [process]
    This will restart the application (or the given process), in a distribution-independent manner.


Topics: Linux MySQL Database SQL svn