Log Cutting | program database backup

Source: Internet
Author: User
Tags rsync

Log Cutting

[Email protected] ~]# cat/root/scripts/cut_logs.sh

#!/bin/bash

#cut Nginx Logs

Nginx_sbin= "/usr/local/nginx/sbin/nginx"

Log_files_path= "/usr/local/nginx/logs"

Cut_log_files_dir= "/data/logs"

Logfilename_array= (www.wifigx.com)

Date= ' Date +%y-%m-%d-d ' 1 days ago '

suffix= ". log.gz"

Projectname= "BBS"

#flush Log to disk

${nginx_sbin}-S Reload


function Cut_gzip_upload ()

{

Gzipfilename=${log_file_name} "_" ${date}${suffix}

MV ${log_files_path}/${log_file_name}.log ${cut_log_files_dir}/${log_file_name}_${date}.log

${nginx_sbin}-S Reload

Gzip-c ${cut_log_files_dir}/${log_file_name}_${date}.log >${cut_log_files_dir}/${gzipfilename}

#upload file to Oss

#/usr/bin/python/root/scripts/upload.py ${gzipfilename} ${projectname}

}


For log_file_name in ${logfilename_array[@]}

Do

Cut_gzip_upload ${log_file_name}

Done


# #delete Log

Find ${cut_log_files_dir}-mtime +30 |xargs rm-rf


General Backup:

#!/bin/bash

# #web-rsync

Rsync-avz/data/wwwroot/web/data/backup/web


# #mysqldump

Date= ' Date +%f '

backupdir=/data/backup/db

CD $backupdir

mkdir $date

CD $date

mysqldump-uroot-p123456 Ultrax >ultrax.sql



###### #delete backup file before 4days#######################

/usr/bin/find ${backupdir}-ctime +6 | Xargs RM-RF


This article is from the "Record Drip" blog, please be sure to keep this source http://caozm.blog.51cto.com/1118764/1618746

Log Cutting | program database backup

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.