Web site Data Automatic backup method _ server Other

Source: Internet
Author: User
Tags mysql backup
Recently because of the national crackdown, so there will inevitably be sealing room, broken network situation, in response to this situation, the most need for stationmaster is to be able to back up their data in time, this article is based on the author's own years of maintenance experience, to share with you under the website data automatic backup experience.

At present Stationmaster most uses the website procedure to have no outside asp\asp.net\php\jsp database, most is Access\sqlserver\mysql

We are divided into 2 kinds of circumstances to explain.

For the win server under the Automatic data backup, Web site files, nature is relatively good backup, then if the database can also be automatically backed up, then the basic realization of the perfect automatic backup.

If you have a standalone server, then this backup work is simpler, let's take a look at the following:

Independent server data offsite automatic backup

Website files we use the Green loop FTP backup software, in the remote server on the green loop FTP, set up a backup task, and then set up a good web site data ftp, the use of green ring automatic backup function, you can easily to the site's files for automatic off-site backup.

Database, we do a backup on the server, and then use the green loop to back up the backup files offsite to the backup server.

MySQL Database: We can use the following batch script:
Copy Code code as follows:

net stop MySQL
xcopy C:\mysql\data\bbs\*.* d:\db_bak\bbs\%date:~0,10%\/y
net start MySQL

For example, set this as a batch file Bak.bat, and then set Windows Scheduled task, run the batch every day, you can automatically back up MySQL, note that the path inside, please modify their own path, c:\mysql\data\bbs\*.* For MySQL data file path, d:\db_bak\bbs\%date:~0,10% behind this for MySQL database backup path.

Some friends of the scheduled task can not run properly, please check the service inside the scheduled Task Scheduler is open, and note that the server has mccafés friends, please note that your mccafés rule settings to see if there are restrictions on the existence of a backup rule.

As for SQL Server, we know that Sqlsever itself has a scheduled backup function, so you can use the same principle for backup, and then offsite backup operations. This article is not detailed here.

In the same way, for MySQL backup under Linux, it is simpler to use the crontab system to regularly back up the MySQL database every day, as detailed settings, this article refers to the following online veteran's practice:

1, create the path to save the backup file/mysqldata

#mkdir/mysqldata

2. Create/usr/sbin/bakmysql files

#vi/usr/sbin/bakmysql

Input

rq= ' Date +%y%m%d '

Tar Zcvf/mysqldata/mysql$rq.tar.gz/var/lib/mysql

or write

rq= ' Date +%y%m%d '

Mysqldump--all-databases-u root-p980405 >/mysqldata/mysql$rq.tar.gz

/var/lib/mysql is the directory of your database files, some users are/usr/local/mysql/data, everyone may be different

/mysqldata/represents the directory where the backup files are saved, and everyone can do it according to their own requirements.

3, modify the file properties to make it executable

# chmod +x/usr/sbin/bakmysql

4. Modify/etc/crontab

#vi/etc/crontab

Add the following

3 * * * root/usr/sbin/bakmysql

Indicates a backup is performed 3 o'clock daily

5. Reboot Crond

#/etc/rc.d/init.d/crond Restart

Complete.

So every day you can see a file like this in/mysqldata.

Mysql20100101.tar.gz

Before the tar command was executed, stop the database service process or lock the database, you can use the time difference to set a scheduled task, suspend the database, or in the backup script to set, note that when using the 2nd hot backup mode, you do not need to stop the MySQL server, otherwise you will not be able to back up.

The above is for opposing server users, so for the virtual host user, I think you can set up Green loop FTP on the local computer, backup files will be no problem, for the database, you can set up an automatic script, every day 0 point trigger this script, about MySQL backup script, online a lot, as to how to trigger, There are many ways, I want to use discuz friends, all know the principle of discuz in the planning task, in addition Dede system also has automatic timing generated HTML script, are the principle.

Of course, for the users of the ASP program, if there is no database, it is much simpler.

Well, the above related settings, then you can realize the data automatic off-site backup, it is no longer afraid of the server was blocked.

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.