A simple way to back up sites and databases on a VPS host other

Source: Internet
Author: User
Tags vps

Now see more and more vpser start using VPS, in the use of VPS when a very important task is to provide backup VPS, although some IDC also provides VPS backup services, but either is the charge, are not very suitable for us to use these vpser.

Today introduce a simple method for your own VPS backup.

1, the use of Putty login VPS, here is not much introduced.

2, Backup Site Directory:

Copy Code code as follows:

[Root@www ~]# cd/web/www/Enter the corresponding directory
[Root@www www]# tar zcvf vps.tar.gz VPS//Use tar packaged and compressed VPS folder, compressed file name: vps.tar.gz
[Root@www www]#

3, BACKUP database:

Method One: Use phpMyAdmin to back up the database

Method Two: Automatically back up the database using mysqldump timing

[Root@www www]# vi backup-db.sh#!/bin/sh 
       
  
/usr/local/mysql/bin/mysqldump-uroot-ppassword databasename >/web/www/db-backup/databasename$ (date + "%Y%m%d"). Sql
rm/web/www/db-backup/databasename$ (date-d -7day + "%y%m%d"). SQL#上面语句删除7天前的备份

The above script-U after the database user name, –p after the database user password,databasename changed to the database name to be backed up, you can also back up all the database will databasename modified to--all-databases, back/web/www/ db-backup/is the directory that is backed up.

Add a timed execution task

[Root@www ~]# crontab-e/root/backup-db.sh    
Daily 23:59 chapters automatically back up the database, and the resulting database compression is named by date
The above backup of the information, the backup is done quickly to download the backup to the local, after all, the backup data are in the VPS, not around.
>> Reprint Please indicate the Source: VPS Detective

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.