Linux regular backup scripts-optimized finalization

Source: Internet
Author: User

One, the script


#!/bin/sh

Dir=/data/ascenlink/logs


#T = ' Find $DRI/*-type f-mtime +365 '

#rm-RF $T


i=$ (df-h |grep-v data2 |awk '/data/{gsub ("'% '", "");p rint $4} ')

If [$I-gt];then

MV $DIR/*.tar.gz/data2/backuplog

echo "No enough free Disk Space for backup" >>/home/ascenlink/backuperror.log

Fi


While True

cpu=$ (vmstat 1 1 |awk ' {print $13} ' |sed-n 3p)

mem=$ (free-m |awk '/mem/{print $} ')

Do

if [[$CPU-GT 90]] | | [[$MEM-GT 8000]];then

Sleep 5m

Else

Break

Fi

Done


#DATE = ' DATE +%y-%m-%d%h%m '

cd/data/ascenlink/logs/

#LOG = ' Find '/-type f-mtime-31-print |xargs '

#wait

#tar-zcvf/data/ascenlink/logs/ascenlink. $DATE. tar.gz $LOG >/dev/null 2>&1


A= ' date-d '-1 months "|awk ' {print $} ' |sed-n 1p '

Date= ' date-d '-1 months "+%y-%m-%d%h%m '


Tar-zcvf/home/ascenlink/ascenlink. $DATE. tar.gz $ (ls-l |grep $A |awk ' {print $9} ') >/dev/null 2>&1


Second, the regular implementation of the task time


Execution time is monthly, 1:1 the log files for the previous one months are packaged


Cat/etc/crontab


1 1 1 */1 * ascenlink/bin/sh/home/ascenlink/logbackup.sh >/dev/null 2 >&1



2010-02-21


This article is from the "Five Corners" blog, please be sure to keep this source http://hi289.blog.51cto.com/4513812/1764636

Linux regular backup scripts-optimized finalization

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.