In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
How to automatically back up website files and databases uploaded to the FTP space, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can get something.
Database backup is sent to Email and FTP space, double backup to ensure the security of the data.
# what you want to change starts here
MYSQL_USER=root # mysql user name
MYSQL_PASS=123456 # mysql password
MAIL_TO=cat@hostloc.com # mailbox to which the database is sent
FTP_USER=cat # ftpl user name
FTP_PASS=123456 # ftp password
FTP_IP=imcat.in # ftp address
The directory on FTP_backup=backup # ftp where backup files are stored. You must build this directory on ftp.
WEB_DATA=/home/www # website data to be backed up
# the place you want to modify ends here
Don't forget to create a directory: mkdir-p / home/backup
If your website data is more than 5G and less than 10G, it will be a little difficult to compress.
If it is less than 5G, there will be no problem. But it all depends on the performance of vps.
First install the Email sending component
Yum install sendmail mutt
The script is as follows:
#! / bin/bash
Cd / home/backup
# define the name of the database and the name of the old database
DataBakName=Data_$ (date + "% Y%m%d").. tar.gz
WebBakName=Web_$ (date +% Y%m%d) .tar.gz
OldData=Data_$ (date-d-5day + "% Y%m%d") .tar.gz
OldWeb=Web_$ (date-d-5day + "% Y%m%d") .tar.gz
# Delete local data 3 days ago
Rm-rf / home/backup/Data_$ (date-d-3day + "% Y%m%d"). Tar.gz / home/backup/Web_$$ (date-d-3day + "% Y%m%d") .tar.gz
# Export mysql database
/ usr/local/mysql/bin/mysqldump-uroot-p123456-databases db1 db2 db3 > / home/backup/databackup.sql
# compress the database
Tar zcf / home/backup/$DataBakName / home/backup/databackup.sql
Rm-rf / home/backup/databackup.sql
# send the database to Email. If the database is too large after compression, please comment on this line
Echo "topic: database backup" | mutt-a / home/backup/$DataBakName-s "content: database backup" www@gmail.com
# compress website data
Tar zcvf / home/backup/$WebBakName / home/www
# upload to FTP space and delete data from 5 days ago in FTP space
Ftp-v-n imcat.in
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.