Difference between revisions of "Backup and Restore Loop"

From PKC
Jump to navigation Jump to search
 
(7 intermediate revisions by the same user not shown)
Line 9: Line 9:


=Step to deploy=
=Step to deploy=
Below are the step to perform Backup and Restore Loop from ansible agent machine.
Below are the step to perform Backup and Restore Loop from ansible agent machine. You need to install ansible on your local machine before you can execute the ansible script, please find the comprehensive methode of installing ansible on [https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html Ansible Installation]
==Get the source code==
==Get the source code==
Download the source code from github link below
Download the source code from github link below
Line 15: Line 15:


==Adjust the configuration==
==Adjust the configuration==
The source code of PKC code is consist of below directory, there are two files that need to adjust before we cant start performing Backup-Restore-Loop. Those files are host-restore in ./resource/config; and cs-restore-remote.yml in ./resource/ansible-yml
The source code of PKC code is consist of below directory, there are two files that need to adjust before we cant start performing Backup-Restore-Loop. Those files are :
# host-restore in ./resource/config
# cs-restore-remote.yml in ./resource/ansible-yml
<pre>
<pre>
.
.
Line 23: Line 25:
         ├── config
         ├── config
         └── script
         └── script
</pre>
file host-restore, please replace values with your specific case.
<pre>
[your-source-server] ansible_connection=ssh ansible_ssh_private_key_file=[.pem] ansible_user=[user] domain=[src-domain]
[your-destination-server] ansible_connection=ssh ansible_ssh_private_key_file=[.pem] ansible_user=[user] domain=[dest-domain]
</pre>
file cs-restore-remote.yml. on header parts
<pre>
- name: Backup and Restore Loop
  hosts: all
  gather_facts: yes
  become: yes
  become_user: root
  vars:
    - pkc_install_root_dir: "/home/ubuntu/cs/"
    - src_server: [put-your-source-server-here]
    - dst_server: [put-your-destiantion-server-here]
  tasks:
... redacted
</pre>
</pre>


==Execute Backup Process==
==Execute Backup Restore Loop Process==
==Execute Restore Process==
To execute, please ensure that you have change the current folder into PKC's project root folder and paste below command.
ansible-playbook -i ./resources/config/hosts-restore ./resources/ansible-yml/cs-restore-remote.yml
As the output of this process is the latest backup of mySQL file and Mediawiki Image file in
PKC\resource\ansible-yml\backup\
Below is the table of output file
{| class="wikitable"
|-
! File Name
! Folder
! Remarks
|-
| *.tar.gz
| ./resource/ansible-yml/backup
| latest backup file with timestamp in filename, each time the process is executed, will generate two backup files.<br />Which are database backup file, and image backup file
|-
| restore_report.log
| ./resource/ansible-yml/backup
| Log of backup-restore-loop output.
|}


=References=
=References=
<references />
<references />
[[Category:DevOps]]
[[Category:DevOps]]
https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html

Latest revision as of 08:36, 18 March 2022

PKC Automatic Backup and Restore Process is a series of command executed on backup-source server and backup-target server. The target of the process loop is to ensure there are always a backup data that can be easily restored into target server. Below is the schematic diagram on how the process is executed.

Backup-restore

Introduction

Configuration process is done by ansible script, that is executed from ansible host. Below are the outline of deployment process in general

  1. Get the source code; From github to your local machine. The source code will contain all necessary ansible script to execute the deployment process.
  2. Adjust the configuration; Adjust configuration on your local machine to define the backup-and-restore loop
  3. Execute Backup Process; Execute backup installation
  4. Execute Restore Process; Execute restore installation

Step to deploy

Below are the step to perform Backup and Restore Loop from ansible agent machine. You need to install ansible on your local machine before you can execute the ansible script, please find the comprehensive methode of installing ansible on Ansible Installation

Get the source code

Download the source code from github link below

git clone https://github.com/xlp0/PKC

Adjust the configuration

The source code of PKC code is consist of below directory, there are two files that need to adjust before we cant start performing Backup-Restore-Loop. Those files are :

  1. host-restore in ./resource/config
  2. cs-restore-remote.yml in ./resource/ansible-yml
.
└── PKC/
    └── resource/
        ├── ansible-yml
        ├── config
        └── script

file host-restore, please replace values with your specific case.

[your-source-server] ansible_connection=ssh ansible_ssh_private_key_file=[.pem] ansible_user=[user] domain=[src-domain]
[your-destination-server] ansible_connection=ssh ansible_ssh_private_key_file=[.pem] ansible_user=[user] domain=[dest-domain]

file cs-restore-remote.yml. on header parts

- name: Backup and Restore Loop
  hosts: all
  gather_facts: yes
  become: yes
  become_user: root
  vars:
    - pkc_install_root_dir: "/home/ubuntu/cs/"
    - src_server: [put-your-source-server-here]
    - dst_server: [put-your-destiantion-server-here]

  tasks:
... redacted

Execute Backup Restore Loop Process

To execute, please ensure that you have change the current folder into PKC's project root folder and paste below command.

ansible-playbook -i ./resources/config/hosts-restore ./resources/ansible-yml/cs-restore-remote.yml

As the output of this process is the latest backup of mySQL file and Mediawiki Image file in

PKC\resource\ansible-yml\backup\

Below is the table of output file

File Name Folder Remarks
*.tar.gz ./resource/ansible-yml/backup latest backup file with timestamp in filename, each time the process is executed, will generate two backup files.
Which are database backup file, and image backup file
restore_report.log ./resource/ansible-yml/backup Log of backup-restore-loop output.

References

https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html