메뉴 건너뛰기

조회 수 863 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

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

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
<?php
require_once './_common.php';

$tables  = [];
$exclude = [
    'g5_autosave'
    'g5_visit',
    'g5_visit_sum'
];

$result = sql_query("SHOW TABLES");

for ($i = 0; $row = sql_fetch_array($result); $i++) {
    $tables[] = array_pop($row);
}

$userInfo = posix_getpwuid(fileowner(__FILE__));
$owner = $userInfo['name'];

$dir = '/home/dbbackup/'.$owner.'/'.date('Ymdhi');
mkdir($dir, 0755, true);

// 7일 초과 경과된 data 삭제
$basedir = dirname($dir);
$basetime = time() - 86400 * 7;

foreach (scandir($basedir) as $val) {
    if (in_array($val, array('.', '..')))
        continue;

    $d = $basedir.'/'.$val;

    if (filemtime($d) < $basetime) {
        if (is_dir($d)) {
            foreach (scandir($d) as $v) {
                if (in_array($v, array('.', '..')))
                    continue;

                if (is_file($d.'/'.$v))
                    @unlink($d.'/'.$v);
            }

            rmdir($d);
        } else {
            @unlink($d);
        }
    }
}

// DB 백업
$host = G5_MYSQL_HOST;
$user = G5_MYSQL_USER;
$pass = G5_MYSQL_PASSWORD;
$database = G5_MYSQL_DB;

foreach ($tables as $table) {
    if (in_array($table, $exclude))
        continue;

    $file = $dir.'/'.$table.'.sql';

    exec("mysqldump --user={$user} --password={$pass} --host={$host} {$database} {$table} --result-file={$file} 2>&1", $output);
}

  1. No Image 29Apr
    by 조쉬
    2019/04/29 Views 863 

    영카트5 DB 테이블별로 덤프하기

  2. No Image 29Apr
    by
    2019/04/29 Views 876 

    그누보드5 검색최적화 방법입니다

  3. No Image 29Apr
    by
    2019/04/29 Views 743 

    쉽고 간편한 인쇄 팁

  4. 특정 게시판에서 이미지 파일만 업로드 허용하기

  5. No Image 13Dec
    by
    2019/12/13 Views 382 

    우측 퀵메뉴

  6. No Image 13Dec
    by
    2019/12/13 Views 255 

    style 수정시 서버에서 로딩되게 하기

  7. No Image 13Dec
    by
    2019/12/13 Views 389 

    이미지에 워터마크 넣기

  8. No Image 13Dec
    by
    2019/12/13 Views 385 

    iframe 금지된 사이트 iframe 으로 불러오기

  9. No Image 13Dec
    by
    2019/12/13 Views 323 

    글 작성시 랜덤형 자동 댓글로 인사 멘트남기기

  10. jQuery 요소(elements) 미디어 컨버팅 플러그인

  11. No Image 13Dec
    by
    2019/12/13 Views 326 

    이름 마지막 한자리 별표 처리

  12. No Image 13Dec
    by
    2019/12/13 Views 317 

    카운트다운 스크립트

  13. No Image 13Dec
    by
    2019/12/13 Views 485 

    네이버 밴드 글 가져오기

  14. 회원 목록을 select 로 불러와서 선택시 input 에 집어넣기

  15. No Image 13Dec
    by
    2019/12/13 Views 1223 

    링크 클릭시 특정영역에 페이지 불러오기 (아이프레임X)

  16. '정상적으로 로그인하여 접근하시기 바랍니다.' 해결 방법

  17. No Image 24Mar
    by
    2021/03/24 Views 146 

    회원 등급(권한)에 따라서 다른 메시지 보이기

  18. No Image 24Mar
    by
    2021/03/24 Views 289 

    그누보드 카카오톡 로그인 V2 플러그인

  19. fullcalendar 달력 게시판 스킨

  20. 그누보드 이력서 스킨

Board Pagination Prev 1 2 3 4 Next
/ 4

하단 정보를 입력할 수 있습니다

© k2s0o1d4e0s2i1g5n. All Rights Reserved