Backup VPS Data with Dropbox

Source: Internet
Author: User
Tags vps

In the VPS data is best scheduled backup, so that the server out of any problems, the data is lost. I use Dropbox to synchronize WordPress folders and database information at timed intervals.

Download Dropbox first

?
1 wget -O dropbox.tar.gz http://www.dropbox.com/download/?plat=lnx.x86

Then unpack the package.

?
1 tarxzvf dropbox.tar.gz

Perform

?
1 ~/.dropbox-dist/dropboxd

A URL will appear here, access this URL, bind server and Dropbox account

Dropbox synced Folders by default is ~/dropbox

?
1 cd~/Dropbox

Next, sync the WordPress folder to Dropbox

?
1 ln-s /home/www(/home/www为wordPress文件夹)

Then back up the MySQL database (~/backup/mysqlbackup.sh)

The script is as follows:

?
12 echo"start mysql back up "${date} >> /root/backup/backup.logmysqldump -uroot -p123456 wordpress >/root/mysqlback.sql

Then connect the Mysqlback.sql to the Dropbox folder

?
1 cd~/Dropbox ln-s ~/backup/mysqlback.sql

Then execute the mysqlbackup.sh regularly.

?
1 crontab-e

At the end of the Add (note first set the mysqlbackup.sh permissions)

?
1 * 3 * * *  /root/backup/mysqlbackup.sh

There's a problem here. Dropbox is always on. For the poor memory and CPU of VPS, it is still a certain burden. And there's no need to keep Dropbox open all the time. Write a script to run and close Dropbox at timed intervals.

Create Script ~/backup/dropboxswitch.sh

The script is as follows

?
010203040506070809101112131415161718192021222324 date=`date +%Y%m%d_%H:%M:%S`start() {        echo "starting dropbox "${date} >> /root/backup/backup.log        /root/dropbox/.dropbox-dist/dropbox &        }stop() {        echo "stoping dropbox "${date} >> /root/backup/backup.log        pkill dropbox        }case "$1" in  start)        start        ;;  stop)        stop        ;;  restart)        stop        start        ;;  esac

The dropbox,6 point is then scheduled to start 4 o'clock in the morning every day.

?
1 crontab-e

Then add the following:

?
12 * 4 * * * /root/backup/dropboxswitch start* 6 * * * /root/backup/dropboxswitch stop

The backup to this VPS is fixed, the use of a relatively simple command, but very effective;)

Backup VPS Data with Dropbox

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.