Linux Scheduled Tasks automatic backup and FTP upload script

Source: Internet
Author: User

#!/bin/sh# backup #bak_dir= ' Date +%c%y%m%d%h%m ' # #文件命名规则可以是时间backup_dir =/home/iptv4.9 # #存储备份文件路径mkdir-P $backup _dirip_ad Dr= ' ifconfig \ ' route |grep default |awk ' {print $8} ' \ ' |grep bcast |awk-f: ' {print $} ' |awk ' {print $} ' host_name= ' hos Tname ' software_file_bak= ' $Ip _addr-$Host _name_ ' Date +%f_%h%m%s '. tgz "mysql_file_bak=" $Ip _addr-$Host _name_ ' Date +%f _%h%m%s '. tgz ' # #可以自行修改备份文件名称, reduce or increase mysql_bak=/var/lib/mysqlftpip=192.168.1.1ftpusr=ftpusernameftppwd= Ftpuserpasswordftppath=/home/back # #ftp备份服务器信息echoecho "Backup.................................,wait ..... ....! "Echocd $backup _dirconfig1=/etc/......config2=/etc/......config3=/home/... # #可以添加跟多的备份文件tar ZCVF $software _file_ Bak $config 1 $config 2 $config 3 >/dev/null 2>&1tar pzcvf $Mysql _file_bak $Mysql _bak--exclude logbin* >/dev/n ull 2>&1 # #数据库备份 # #上传文件到ftp服务器ftp-n $ftpip <<!user $ftpusr $ftppwdbinmkdir $FTPPATHCD 7200 $ftppathhashidle Prompt offput *.tgzby!sleep 10find $backup _dir/*.tgz -mtime +7-exec rm-fr {} \; >/dev/null 2>&1 # #删除7天前文件, can be modified

Simple backup scripts that can be modified at the root of their own needs.

This article is from the "Technical Exchange" blog, please be sure to keep this source http://linuxsuperman.blog.51cto.com/2219295/1412643

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.