MySQL database backup and remote copy implementation

Source: Internet
Author: User
Tags chmod file permissions rsync

I. Implementing SSH remote Login

Machine Environment:

192.167.33.108 clent User: Crawler

192.167.33.77 Server User: Crawler

1. Client- generated key

/home/crawler/.ssh/ssh-keygen

2. View Key file permissions

Ls-ld ~/.ssh; Ls-l ~/.ssh

3. Modify File Permissions

chmod 700/home/crawler/.ssh

chmod 600/home/crawler/. SSH/id_rsa

4. Copy the public key to the server side

Scp-r /home/crawler/. SSH/id_rsa.pub [email protected]:/home/crawler/. SSH

5. Setting the public key on the server side


Need to be drwx
Ls-l/home/crawler/.ssh/*pub See if there is a public key
/home/crawler/.ssh/authorized_keys//Generate public key It's best to avoid replacing the previous public key in this way
/home/crawler/.ssh/authorized_keys//Modify Permissions
/HOME/CRAWLER/.SSH//View permissions

6.ssh [email protected] Login successful

Second, backup MySQL database

1. Backup script (start Backup daily 3 o'clock in the morning 30, keep only 7 days of backup data)

* * * * * sh/home/crawler/mysql_back_up/script/mysql-backup.sh GQUAN_MISS8

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

Echo backuping $

mysqldump-uroot-p111111--default-character-set=utf8--opt--triggers-r--hex-blob--single-transaction $ | gzip >/home/crawler/mysql_back_up/daily/$1-all-$RQ. sql.gz

Find/home/crawler/mysql_back_up/daily-mtime +7-name "*.sql.gz"-exec rm-rf {} \;

Echo Finished backup $

2.rsync incremental synchronization of remote backup data (performed 5:10 A.M. daily)

* * * * * sh/home/crawler/mysql_back_up/script/back_mysql_77.sh >>/home/crawler/mysql_back_up/script/ Back.log

#!/bin/sh
echo "------------------------start--------------" ' Date '
Rsync-au--delete/home/crawler/mysql_back_up/daily/[Email protected]:/home/crawler/back_96_data
echo "------------------------over--------------" ' Date

3. Test View server with client file description correct

Server pictures

Client pictures



MySQL database backup and remote copy implementation

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.