Rsync +crontab Implement scheduled backup files

Source: Internet
Author: User

For example, the/www directory on the Web server is backed up to the rsync server.

rsync:192.168.1.10 web:192.168.1.11

1 Configuring the Rsync server

Create a System user Useradd-s/sbin/nologin-m rsync

Create Directory Mkdir/backup

Chown-r rsync.rsync/backup/

vim/etc/rsyncd.conf Copy the content below


UID = rsync

GID = rsync

Use chroot = no

Max connections = 200

Timeout = 300

PID file =/var/run/rsyncd.pid

Lock file =/var/run/rsync.lock

Log file =/var/log/rsyncd.log

[Backup] (module, can be arbitrary, but the Web server connection should be noted (in the script:: Backup). )

Path =/tmp/backup/(important)

Ignore errors

Read Only = False

List = False

Hosts allow = 192.168.1.0/24 (specify reachable IP)

Hosts Deny = 0.0.0.0/32 (other deny)

Auth users = Renkun (authentication user)

Secrets file =/etc/rsync.password

To create a user-connected file

Create user Renkun Password 1234

Useradd renkun-p 1234

Create a password file

Vim/etc/rsync.password

renkun:1234

Change permissions (required)

chmod 600/etc/rsync.password

Start the daemon process

Rsync--daemon

View Port 873 Open

Netstat-tnl

Web server-side configuration

Configure password file

Vim/etc/rsync.password

1234

Create an automatic upload script

vim/zd.sh

#!bin/bash

I= "' Date +%y-%m-%d-%h-%m '"

#echo "$i"

tar-zcvf/tmp/$i. tar.gz/www

rsync-avz/tmp/$i. tar.gz [Email protected]::backup--password-file=/etc/rsync.password

rm-rf/tmp/$i. tar.gz

Configuring Crontab Periodic uploads

Crontab-e

30 23 * * *. /zd.sh (minutes, hours, days, months, weeks: 23:30 every day. The test can be uploaded per minute using * * * * * * *

Complete





This article is from the "Itcain" blog, make sure to keep this source http://521kun.blog.51cto.com/9397206/1773526

Rsync +crontab implementing scheduled backup files

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.