조회 수 858 추천 수 1 댓글 1
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
Extra Form
라이선스 MIT
#!/bin/bash

# Copyright (C) 2017 Study For Us HOSTING (https://hosting.studyforus.com)
# The Site Mirroring Tool (For RHYMIX)
# Version information : 0.1 (Proto type)
# License : The MIT License (MIT)

# DEFINE ORIGINAL SERVER VARS
ORIGIN_HOST='ORIGIN_server_host'# ORIGINAL SERVER HOST
ORIGIN_DB_HOST='db_host'# ORIGINAL DB HOST
ORIGIN_DB_NAME='db_name'# ORIGINAL DB NAME
ORIGIN_DB_USER='db_user_name'# ORIGINAL DB USER NAME
ORIGIN_DB_PASSWD='db_user_password'# ORIGINAL DB USER PASSWORD
ORIGIN_WEB_DIR='absolute_file_path'# ONLY ABSOLUTE PATH
ORIGIN_USER='user_name'# SSH USER NAME
ORIGIN_DOMAIN='www.domain.com'# ORIGINAL DOMAIN URL
DB_PREFIX='rx_'# DB PREFIX (Basically rx_ or xe_)

# DEFINE MIRROR SERVER VARS
MIRROR_HOST='hostname'# MIRROR SERVER HOST
MIRROR_DB_HOST='db_host'# MIRROR DB HOST
MIRROR_DB_NAME='new_db_name'# MIRROR DB NAME
MIRROR_DB_USER='new_db_user'# MIRROR DB USER NAME
MIRROR_DB_PASSWD='new_db_password'# MIRROR DB USER PASSWORD
MIRROR_WEB_DIR='new_web_path'# MIRROR WEB DIRECTORY (ABSOLUTE PATH)
MIRROR_DOMAIN='www.mirror.com'# MIRROR DOMAIN URL


# Move to web directory.
echo "Move to new web diretory."
cd $MIRROR_WEB_DIR

# Dumping original DB to web directory on mirror server.
echo "Dumping DB to new web directory."
mysqldump -h$ORIGIN_DB_HOST -u$ORIGIN_DB_USER --password=$ORIGIN_DB_PASSWD  --single-transaction $ORIGIN_DB_NAME > $ORIGIN_DB_NAME.sql
echo ""
echo "done."
echo ""
echo ""

# Copying the original DB to new DB.
echo "Restore DB to new site."
mysql -h$MIRROR_DB_HOST -u$MIRROR_DB_USER --password=$MIRROR_DB_PASSWD  $MIRROR_DB_NAME < $ORIGIN_DB_NAME.sql
echo ""
echo "done."
echo ""
echo ""


# Delete DB file after dumping.
echo "Removing DB backup file."
rm $ORIGIN_DB_NAME.sql
echo ""
echo "done."
echo ""
echo ""

# Copying web files to mirror server via rsync
echo "Coping web files to new site web directory."
rsync -azh --delete $ORIGIN_USER@$ORIGIN_HOST:$ORIGIN_WEB_DIR/ $MIRROR_WEB_DIR/
echo ""
echo "done."
echo ""
echo ""

# Back up config.php file
echo "Back up config file."
cp files/config/config.php files/config/config.php.bak
echo ""
echo "done."
echo ""
echo ""

# Modifying DB information from config.php
echo "Changing DB information in config.php file"
sed -i "s/$ORIGIN_DB_NAME/$MIRROR_DB_NAME/g" $MIRROR_WEB_DIR/files/config/config.php
echo "DB name changed."
sed -i "s/$ORIGIN_DB_USER/$MIRROR_DB_USER/g" $MIRROR_WEB_DIR/files/config/config.php
echo "DB user name changed"
sed -i "s/$ORIGIN_DB_PASSWD/$MIRROR_DB_PASSWD/g" $MIRROR_WEB_DIR/files/config/config.php
echo "DB password changed."
echo ""
echo "All DB information changed."
echo ""
echo ""

# Changing domain name in DB. 
echo "Changing site domain information to information in DB."
mysql -h$MIRROR_DB_HOST -u$MIRROR_DB_USER -p$MIRROR_DB_PASSWD $MIRROR_DB_NAME -e "UPDATE ${DB_PREFIX}domains SET domain = \"${MIRROR_DOMAIN}\" WHERE domain = \"${ORIGIN_DOMAIN}\";"
mysql -h$MIRROR_DB_HOST -u$MIRROR_DB_USER -p$MIRROR_DB_PASSWD $MIRROR_DB_NAME -e "UPDATE ${DB_PREFIX}sites SET domain = \"${MIRROR_DOMAIN}\" WHERE domain = \"${ORIGIN_DOMAIN}\";"
echo ""
echo "done."
echo ""
echo "Site migration(mirroring) complete."


처음 부분에 변수만 설정해주고 실행하면 자동으로 서버 이전이 완료됩니다.

  • profile
    이니스프리 2018.01.14 20:23
    그러지 않아도 미러링에 대해 공부하고 싶었는데 감사합니다! ^-^

  1. 세린서버에서 시도중인 백업 스크립트 입니다.

    Date2017.06.27 Category코드 ByNoYeah Views745
    Read More
  2. AdminLTE용 에디터 스타일

    Date2017.07.07 Category자료 Bytitle: 은메달도다 Views770
    Read More
  3. [PHP/Javascript] 아미나에 자동으로 게시글을 생성하고 Ajax로 전송하여 결과를 표시하기

    Date2019.07.09 Category코드 By이니스프리 Views777
    Read More
  4. even_move - 감성적인 에러 페이지

    Date2017.08.08 Category자료 Bytitle: 열려라 맛스타의 자물쇠TVJ Views798
    Read More
  5. Gentelella

    Date2017.06.29 Category자료 ByNoYeah Views806
    Read More
  6. 폰트를 자동 설치하는 코드

    Date2018.07.16 Category코드 By네모 Views831
    Read More
  7. [오토핫키] 브라우저를 열어 지난번과 동일한 폴더에 MZK를 다운받고 압축을 네이티브로 해제하는 스크립트

    Date2018.10.20 Category코드 By이니스프리 Views841
    Read More
  8. [PHP] 기상청 RSS 시간별 예보 위젯 - cache 적용(?)

    Date2018.10.28 Category코드 By이니스프리 Views850
    Read More
  9. 사이트 서버 이전 (또는 미러링 사이트 구축) 쉽게하는 스크립트

    Date2018.01.14 Category코드 ByNoYeah Views858
    Read More
  10. 소셜XE / 기존 통합 로그인 스킨 V2.2

    Date2017.06.28 Category자료 ByNoYeah Views909
    Read More
  11. 유튜브에 약간의 기능을 추가 해주는 크롬 확장 프로그램.

    Date2018.01.26 Category코드 ByHanam09 Views942
    Read More
  12. [Python] Google Image Search 결과를 받아오기

    Date2019.12.09 Category코드 By이니스프리 Views949
    Read More
  13. 잘못 쓰면 컴퓨터가 날아가는 코드

    Date2018.07.08 Category코드 By제르엘 Views964
    Read More
  14. [아미나] 네이트 실시간 검색어 순위 위젯 (아미나 캐시 적용)

    Date2018.12.18 Category코드 By이니스프리 Views975
    Read More
  15. [PyQt] sir.kr에서 스크랩한 게시글을 보여주는 윈도우앱 (검색 및 정렬 가능)

    Date2019.08.09 Category코드 By이니스프리 Views1000
    Read More
  16. [Python] 선택한 파일을 Dropbox API를 이용하여 업로드하고 공유링크를 받아서 이미지 호스팅 용도로 URL을 변환하기

    Date2019.07.02 Category코드 By이니스프리 Views1005
    Read More
  17. CMD로 로컬 연결 고정 IP 설정하기

    Date2018.02.06 Category코드 Bytitle: 황금 서버 (30일)humit Views1038
    Read More
  18. [Python] 유튜브 영상을 다운받아 일정 간격으로 캡쳐하여 10장씩 merge하기

    Date2020.05.27 Category코드 By이니스프리 Views1063
    Read More
  19. 클라이언트단에서 이미지 리사이징

    Date2018.05.06 Category코드 By네모 Views1078
    Read More
  20. 컴퓨터의 uuid 얻기

    Date2018.01.28 Category코드 Bytitle: 황금 서버 (30일)humit Views1099
    Read More
Board Pagination Prev 1 2 3 4 Next
/ 4