In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "Linux website and database automatic local backup and FTP upload how to achieve", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "Linux website and database automatic local backup and FTP upload how to achieve" it!
Preparatory work:
Need to install the lftp,lftp function on vps in advance. Centos directly executes: yum install lftp,debian execution: apt-get install lftp.
You need to create a / home/backup/ directory on vps and a backup directory on ftp.
If there are not many databases on vps, you can use the free space of godaddy (10gb space, 300gb traffic). As long as you register a domain name, it will be given away for free.
Here is a partial comment on the backup script:
The copy code is as follows:
#! / bin/bash
# funciont: backup website and mysql database
# author: licess
# website: http://lnmp.org
# important!!!please setting the following values!
# ~ set directory you want to backup~# modify the following directory to the directory you want to back up. Generally, you write all the directories to be backed up directly under / home/wwwroot/ according to mine. You can continue to add: backup_dir5= your directory, and the numbers after backup_dir are incremented in turn. If there are less than 4, just delete what you don't need and modify the tar zcf section below.
Backup_dir1=vpser.net
Backup_dir2=lnmp.org
Backup_dir3=licess.org
Backup_dir4=jungehost.com
# ~ set mysql username and password~# sets the user name and password of mysql, preferably root. Other users may not be able to export part of the database due to permission issues.
Mysql_username=root
Mysql_password=yourmysqlrootpassword
# ~ if you want to set the part of the database in set mysql database you want to backup~#, you can continue to add: backup_database_name5= database name, and the number after backup_database_name is incremented in turn.
Backup_database_name1=vpser
Backup_database_name2=licess
Backup_database_name3=junge
Backup_database_name4=vpserorg
# ~ set ftp information~# sets the ftp information used to store backup data
The ip or domain name of the ftp_hostname=184.168.192.43 / / ftp server
Ftp_username=vpsernet / / ftp server username
Password for ftp_password=yourftppassword / / ftp server user
Ftp_backupdir=backup / / back up to the directory on ftp, which needs to be created in advance.
# values setting end!
Todaywwwbackup=www-*-$ (date + "% y%m%d") .tar.gz
Todaydbbackup=db-*-$ (date + "% y%m%d") .sql
Oldwwwbackup=www-*-$ (date-d-3day + "% y%m%d") .tar.gz
Olddbbackup=db-*-$ (date-d-3day + "% y%m%d") .sql
Tar zcf / home/backup/www-$backup_dir1-$ (date + "% y%m%d") .tar.gz-c / home/wwwroot/ $backup_dir1--exclude=soft
Tar zcf / home/backup/www-$backup_dir2-$ (date + "% y%m%d") .tar.gz-c / home/wwwroot/ $backup_dir2
Tar zcf / home/backup/www-$backup_dir3-$ (date + "% y%m%d") .tar.gz-c / home/wwwroot/ $backup_dir3--exclude=test
Tar zcf / home/backup/www-$backup_dir4-$ (date + "% y%m%d") .tar.gz-c / home/wwwroot/ $backup_dir4
# the above is to back up the file data of the website, because my website is fragmented, and some directories under the website directory belong to temporary directories and do not need to be backed up, so you can add-- directories that are not backed up by exclude=. If you add backup_dir5=yourdir before it, then add tar zcf / home/backup/www-$backup_dir5-$ (date + "% y%m%d") .tar.gz-c
/ home/wwwroot/ $backup_dir5. Delete redundant rows if redundant.
/ usr/local/mysql/bin/mysqldump-u$mysql_username-p$mysql_password $backup_database_name1 > / home/backup/db-$backup_database_name1-$ (date + "% y%m%d") .sql
/ usr/local/mysql/bin/mysqldump-u$mysql_username-p$mysql_password $backup_database_name2 > / home/backup/db-$backup_database_name2-$ (date + "% y%m%d") .sql
/ usr/local/mysql/bin/mysqldump-u$mysql_username-p$mysql_password $backup_database_name3 > / home/backup/db-$backup_database_name3-$ (date + "% y%m%d") .sql
/ usr/local/mysql/bin/mysqldump-u$mysql_username-p$mysql_password $backup_database_name4 > / home/backup/db-$backup_database_name4-$ (date + "% y%m%d") .sql
# above is the backup of mysql database. If you add backup_database_name5=yourdatabasename before, add / usr/local/mysql/bin/mysqldump-u$mysql_username-p$mysql_password $backup_database_name5 > / home/backup/db-$backup_database_name5-$ (date + "% y%m%d") .sql. Delete redundant rows if redundant.
Rm $oldwwwbackup
Rm $olddbbackup
# Delete backups 3 days ago #
Cd / home/backup/
# the following is the automatic upload section. I have to say that lftp is very powerful. Abandon ftp #
Lftp $ftp_hostname-u $ftp_username,$ftp_password
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.