Automatically backs up website data and sends it to a remote FTP server

Source: Internet
Author: User
Tags remote ftp server
Sometimes a website data is needed, but we cannot always view it. & nbsp; so we can automatically back up website data and send it to our ftp server (preferably for free www.godaddy.com application) to back up Website Data. Today, we wrote a shell script on VPS, use crontab to customize website data

Sometimes a website data is needed, but we cannot always view it.

 
Therefore, we can automatically back up website data and send it to our ftp server (preferably free www.godaddy.com application) to back up Website Data. Today, we wrote a shell script on VPS, use crontab to automatically back up website data. The following is the shell script I used (note: The shell script name is backup. sh: put it in the/root directory. the mysql installation directory is/usr/local/mysql, and the website root directory is/home/wwwroot/31sky.net, modify the shell script according to your actual situation ):
 
#! /Bin/bash
/Usr/local/mysql/bin/mysqldump-u mysql username-p mysql password mysql database name>/home/wwwroot/36pl.com/$ (date + % Y % m % d) -36pl. SQL
Cd/home/wwwroot/36pl.com
Tar-zcvf $ (date when policyymm1_d0000-36pl.com.tar.gz ./*
 
Echo "IP address of open ftp
User ftp username ftp password
Bin
Prompt off
Mput $ (date when policyuncmdemo-36pl.com.tar.gz
Printf ""
Close
Bye "| ftp-I-n
Rm-rf $ (date + % Y % m % d)-36pl. SQL $ (date 1_policy1_m1_d1_-36pl.com.tar.gz
 
 
Modify the backup. sh permission so that it has executable permissions.
 
 
Chmod + x backup. sh
 
Finally, set crontab:
 
 
Crontab-e
 
Add a line (backup starts at every day ):
 
 
10 00 ***/root/backup. sh
 
Note: In some cases, after crontab is set but it does not run, you can restart crontab:
 
 
Service crond restart
 

Related Article

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.