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.
?
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
?
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 .log mysqldump -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.
?
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.
?
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