Diadem Technologies Support Knowledgebase

How to synchronize data through Github

Article ID: 1118
Last updated: 25 Jul, 2018

Synchronizing Httpdoc's data between two server through Github

Push data from plesk server to Github repository
          Creating Github account and reposetory.
          Configure and Initialize Git at Plesk server.
          Upload web content from Plesk server to Github account.
          Update new uploaded content between two plesk servers.
          Update automatically new uploaded content between two plesk servers through GITHUB

PULL data from Github repository to plesk server
          Activity at Source server to synchronize the Data.
          Automatic PULL data update to plesk server through WEBHOOK.

Push data to Github repository from plesk server: gitpush.diadem-tech.com

     Step-01: Creating Github account and reposetory

1. Signup and create a Github account through below given link
    Link: https://github.com/join

2. Now login to the Github account and create new repository at Github named: gittransfer.


     Step-02: Configure and Initialize Git at Plesk server

1. Go to the domain’s httpdocs at the server, from where the updated content will be upload.
          # cd /var/www/vhosts/gitpush.diadem-tech.com/httpdocs

2. Initialize the local directory as a Git repository.
          # git init
    Initialized empty Git repository in /var/www/vhosts/gitpush.diadem-tech.com/httpdocs/.git/

3. Adds the file to your local repository and stages it for commit.
          # git add -u .

4. Commits the tracked changes and prepares them to be pushed to a remote repository.
    To remove this commit and modify the file, use 'git reset --soft HEAD~1' and commit and add the file again.
          # git commit -m 'init repository commit'

[master (root-commit) d728c68] init repository commit
Committer: root <[email protected]>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:
...git config --global user.name "Your Name"
...git config --global user.email [email protected]
If the identity used for this commit is wrong, you can fix it with:
git commit --amend --author='Your Name <[email protected]>'
1 files changed, 28 insertions(+), 0 deletions(-)
create mode 100644 anirban.txt

5. If we push/pull the data content to remote repository at Github, we need to add the RSA public key to Github of that particular systems.
          # ssh-keygen -t rsa -b 4096 -C "[email protected]"        

6. Now copy the SSH public key and put in to Github
          Settings --> SSH and GPG keys --> Add key
          # cat id_rsa.pub

ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAgEAyi2k3ixu/nItYYf5md5qc51/WyOldfCn5KlsxXhZvUgzo4ZxLI2XJR/gyGmclg/h/+1H7ORlqUd1EKFgeE9N8X7E1IMRVQc0OzDFR3Qaynxtal5rl6WsxNcLdxSudWRsyLw+AtBWNej+026KQGiz1H7bpRRtC
/1d4FU3Y9Xyw6GdD6sz4uI1gZUgdYbXAiJDtfwkPCtK4sMYzgWYcZjKdp9qiQ5/3isHqTEYhdJKB69ipLIKl2WtvgoPo6JxpCzbch
LJmOgBciIQQRz7ibZmbbCQhwEyZ4eaDs4zWnr7sr0im0NoWb2BdT3RavCkwmtw5dqQ97dz4KoZrcu3eHtfPLpP2NqXRC/aAD
x1EnpjdIfuahcRbZk5+Ib+LHZOWRPn+6r25d5LxTwqTrQi2Av6MfsYK+Zmin2LomVltBReekDQIkhq9r8tgpFDhL7wXfYxfsJc+8S
wOyEq4ZiH9BiHL9o0uQp6Rj6TPbs+3BLTB3RoGcxYANsvUcnAQQrpmfy4SefTZ65bD9lnH0m5aQK+F7a0bDKEhNd+YkCgJc
KwMqYDJxcpnlPKhAvRQ/kTXN5s= [email protected]


7. At the top of your GitHub repository's Quick Setup page, please click Clone or download tab to copy the remote repository URL.

     Step-03: Upload web content from Plesk server to Github account through Git.

8. From the command prompt, add the (SSH or HTTPS) URL for the remote repository where our local repository will be pushed.
          # git remote add origin [email protected]:anirbandasdiadem/gittransfer.git
OR
          # git remote add upstream https://github.com/anirbandasdiadem/gittransfer.git

9. Verifies the new remote URL
          # git remote -v
                    origin  [email protected]:anirbandasdiadem/gittransfer.git (fetch)
                    origin  [email protected]:anirbandasdiadem/gittransfer.git (push)
                    upstream        https://github.com/anirbandasdiadem/gittransfer.git (fetch)
                    upstream        https://github.com/anirbandasdiadem/gittransfer.git (push)

10. Push the changes in your local repository to GitHub.
          # git push --force -u origin master
                    Password:***********
                    Counting objects: 7, done.
                    Compressing objects: 100% (6/6), done.
                    Writing objects: 100% (6/6), 671.88 KiB, done.
                    Total 6 (delta 0), reused 0 (delta 0)
                    remote:   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                    remote:                                  Dload  Upload   Total   Spent    Left  Speed
                    remote:   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
            To http://[email protected]/plesk-git/gitpushtest.git
            7545e7d..bf0fcfe  master -> master
                    Branch master set up to track remote branch master from origin.

     Step-04: Update new uploaded content between two plesk servers through GITHUB

1. Adds the file to your local repository and stages it for commit.
          [root@diademtest httpdocs]# git add -u .

2. Show the working tree status.
          [root@diademtest httpdocs]# git status
                    # On branch master
                    # Changes to be committed:
                    #   (use "git reset HEAD <file>..." to unstage)
                    # new file:   Jelastic auto scalling.png
                    #       new file:   ZimbraZRTClient-141031_0212-1.zip
                    #       new file:   header2.jpg
                    #       new file:   jelastic-SSH.png
                    #       new file:   jiwan.com-axisbank.PNG
                    #       new file:   keyword-not-exists.png
                    #       new file:   logo-diadem.jpg
                    #       new file:   logo-diadem.png
                    #       new file:   newfile.html
                    # Changed but not updated:
                    #   (use "git add/rm <file>..." to update what will be committed)
                    #   (use "git checkout -- <file>..." to discard changes in working directory)
                    #       deleted:    index.html
                    # Untracked files:
                    #   (use "git add <file>..." to include in what will be committed)
                    #       .well-known/

3. Commit the file that you've staged in your local repository.
          [root@diademtest httpdocs]# git commit -m 'init repository commit'
                   [master e89a1d3] init repository commit
                    Committer: root <[email protected]>
                   Your name and email address were configured automatically based
                   on your username and hostname. Please check that they are accurate.
                   You can suppress this message by setting them explicitly:
                   git config --global user.name "Your Name"
                   git config --global user.email [email protected]
                   If the identity used for this commit is wrong, you can fix it with:
                   git commit --amend --author='Your Name <[email protected]>'
                   9 files changed, 8 insertions(+), 0 deletions(-)
                   create mode 100644 Jelastic auto scalling.png
                   create mode 100644 ZimbraZRTClient-141031_0212-1.zip
                   create mode 100644 header2.jpg
                   create mode 100644 jelastic-SSH.png
                   create mode 100644 jiwan.com-axisbank.PNG
                   create mode 100644 keyword-not-exists.png
                   create mode 100644 logo-diadem.jpg
                   create mode 100644 logo-diadem.png
                   create mode 100644 newfile.html

4. Verifies the new remote URL
          [root@diademtest httpdocs]# git remote -v
                   origin  [email protected]:anirbandasdiadem/gittransfer.git (fetch)
                   origin  [email protected]:anirbandasdiadem/gittransfer.git (push)
                   upstream        https://github.com/anirbandasdiadem/gittransfer.git (fetch)
                   upstream        https://github.com/anirbandasdiadem/gittransfer.git (push)

5. Pushes the changes in your local repository up to the remote repository you specified as the origin.
          [root@diademtest httpdocs]# git push --force -u origin master
                   Counting objects: 12, done.
                   Compressing objects: 100% (11/11), done.
                   Writing objects: 100% (11/11), 2.26 MiB | 691 KiB/s, done.
                   Total 11 (delta 1), reused 0 (delta 0)
                   remote: Resolving deltas: 100% (1/1), completed with 1 local object.
                   To [email protected]:anirbandasdiadem/gittransfer.git
                      216b319..e89a1d3  master -> master
                   Branch master set up to track remote branch master from origin.

     Step-05: Update automatically new uploaded content between two plesk servers through GITHUB

To automatically update the new uploaded content and remove the deleted content from httpdocs we need to create a small
bash script and set it to a cron job.
          # vim /root/scripts/gitpush.sh
                   #!/bin/bash
                   cd /var/www/vhosts/gitpush.diadem-tech.com/httpdocs
                   git add -u .
                   git commit -m 'init repository commit'
                   git push --force -u origin master

          # crontab -e
                   */1    *       *       *       *       /root/scripts/gitpush.sh

PULL data from Github repository to plesk server: gitpull.diadem-tech.com

     Step-01: Activity at Source server to synchronize the Data from Github and destination server.

1. Go to the git at plesk server and add the SSH link from Github.

2. Now copy the SSH public key and put in to Github.
          Settings --> SSH and GPG keys --> Add key


3. Please click on Pull Update tab when we need to update the content at remote server through Github.


4. Now we can find it from file manager the updated data.

     Step-02: Automatic PULL data update to plesk server through WEBHOOK: gitpull.diadem-tech.com

1. We can perform the Pull Update automatically to the destination server through Webhook.
2. Go to the repository settings from plesk panel.


3. Copy the Webhook URL and select the deploy mode Automatic.


4. Now go to the Github account and add the Webhooks URL and activate it from Github bucket settings.



 

This article was:  
Report an issue
Article ID: 1118
Last updated: 25 Jul, 2018
Revision: 28
Views: 828
Comments: 0