add rsync module
This commit is contained in:
parent
b6a66906d3
commit
ee3ac2f8ec
|
@ -0,0 +1 @@
|
|||
*~
|
12
README.md
12
README.md
|
@ -1,4 +1,14 @@
|
|||
configure
|
||||
=========
|
||||
|
||||
This repo includes lots of configure scripts, which can be used in server and desktop.
|
||||
## INTRO
|
||||
This repo includes lots of configure scripts, which can be used in
|
||||
server and desktop.
|
||||
|
||||
## AUTHOR
|
||||
Aborn Jiang (aborn.jiang@gmail.com)
|
||||
|
||||
## VERSION
|
||||
* 2014-01-21 v0.1 (add rsync configure files)
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
rsync
|
||||
=========
|
||||
|
||||
## INTRO
|
||||
Rsync is a very common and useful backup tool, this subrepo aims to
|
||||
configure rsync server and client. *SHELL-SCRIPT*
|
||||
|
||||
## FILE-SERVER
|
||||
* rsync in server path /etc/default/rsync.
|
||||
* rsyncd.conf in server path /etc/rsyncd.conf.
|
||||
* rsyncd.scrt secret file in server /etc/rsyncd.scrt, chmod 600
|
||||
rsyncd.scrt (other usrs cannot read, write and excute).
|
||||
|
||||
## FILE-CLIENT
|
||||
* rsyncd.scrt as rsyncd.scrt in FILE-SERVER.
|
||||
* rsyncclient.sh client backup script.
|
||||
* client.conf clinet configure files.
|
||||
|
||||
## HOW-TO-INSTALL
|
||||
1. in server: configure /etc/default/rsync with ./rsync
|
||||
2. in server: configure /etc/rsyncd.conf and choose backup directory
|
||||
3. in server: running rsync as daemon process: sudo /etc/init.d/rsync
|
||||
start
|
||||
4. in client: configure ./client.conf
|
||||
5. in client: configure ./rsyncclient.sh
|
||||
|
||||
## REFS
|
||||
* link
|
||||
[office website](http://rsync.samba.org/ftp/rsync/rsyncd.conf.html
|
||||
"rsync manual.")
|
||||
|
||||
## CRONTAL
|
||||
* crontab setting: */30 * * * * /home/aborn/backup/rsyncclient.sh >> /home/aborn/backup/client.log 2>&1
|
||||
|
||||
## AUTHOR
|
||||
Aborn Jiang (aborn.jiang@gmail.com)
|
||||
|
||||
## VERSION
|
||||
2014-01-21 v0.1
|
|
@ -0,0 +1,15 @@
|
|||
# this is a configure file for client backup machine
|
||||
# NOTE:
|
||||
# OPTIONS="-vazu --progreess --delete"
|
||||
# client will backup all same files at server
|
||||
# when server delete a specific file, client also delete it.
|
||||
# and OPTIONS="-vazu --progress"
|
||||
# client will keep server deleted files
|
||||
# MODULE responding to [modules] in server, seperated by space
|
||||
# BACKUPPATH client backup path
|
||||
|
||||
BACKUPPATH="/home/aborn/backup/";
|
||||
SERVERIP="10.141.247.12"
|
||||
MODULE="appbackup databackup"
|
||||
#OPTIONS="-vazu --progress --delete"
|
||||
OPTIONS="-vazu --progress"
|
|
@ -0,0 +1,41 @@
|
|||
# defaults file for rsync daemon mode
|
||||
|
||||
# start rsync in daemon mode from init.d script?
|
||||
# only allowed values are "true", "false", and "inetd"
|
||||
# Use "inetd" if you want to start the rsyncd from inetd,
|
||||
# all this does is prevent the init.d script from printing a message
|
||||
# about not starting rsyncd (you still need to modify inetd's config yourself).
|
||||
RSYNC_ENABLE=true
|
||||
|
||||
# which file should be used as the configuration file for rsync.
|
||||
# This file is used instead of the default /etc/rsyncd.conf
|
||||
# Warning: This option has no effect if the daemon is accessed
|
||||
# using a remote shell. When using a different file for
|
||||
# rsync you might want to symlink /etc/rsyncd.conf to
|
||||
# that file.
|
||||
# RSYNC_CONFIG_FILE=
|
||||
|
||||
# what extra options to give rsync --daemon?
|
||||
# that excludes the --daemon; that's always done in the init.d script
|
||||
# Possibilities are:
|
||||
# --address=123.45.67.89 (bind to a specific IP address)
|
||||
# --port=8730 (bind to specified port; default 873)
|
||||
RSYNC_OPTS=''
|
||||
|
||||
# run rsyncd at a nice level?
|
||||
# the rsync daemon can impact performance due to much I/O and CPU usage,
|
||||
# so you may want to run it at a nicer priority than the default priority.
|
||||
# Allowed values are 0 - 19 inclusive; 10 is a reasonable value.
|
||||
RSYNC_NICE=''
|
||||
|
||||
# run rsyncd with ionice?
|
||||
# "ionice" does for IO load what "nice" does for CPU load.
|
||||
# As rsync is often used for backups which aren't all that time-critical,
|
||||
# reducing the rsync IO priority will benefit the rest of the system.
|
||||
# See the manpage for ionice for allowed options.
|
||||
# -c3 is recommended, this will run rsync IO at "idle" priority. Uncomment
|
||||
# the next line to activate this.
|
||||
# RSYNC_IONICE='-c3'
|
||||
|
||||
# Don't forget to create an appropriate config file,
|
||||
# else the daemon will not start.
|
|
@ -0,0 +1,77 @@
|
|||
#!/bin/bash
|
||||
##################################################################
|
||||
# NAME
|
||||
# rsyncclient.sh ---- running in client machine, which
|
||||
# is used to backup data in client machine
|
||||
#
|
||||
# USAGE
|
||||
# ./rsyncclient.sh
|
||||
#
|
||||
# AUTHOR
|
||||
# Aborn Jiang (aborn.jiang@gmail.com)
|
||||
#
|
||||
# NOTE
|
||||
# pls configure the file client.conf and rsyncd.scrt
|
||||
#
|
||||
##################################################################
|
||||
ABSPATH=$(dirname $0)
|
||||
source ${ABSPATH}/client.conf
|
||||
|
||||
function get-user-pwd()
|
||||
{
|
||||
# obtain usrname and password
|
||||
iUSR=$(cat ${ABSPATH}/rsyncd.scrt|tr -d ' ' |grep -v "^$" | \
|
||||
grep -v "^#"|head -n 1|awk -F : '{print $1}')
|
||||
iPWD=$(cat ${ABSPATH}/rsyncd.scrt|tr -d ' ' |grep -v "^$" | \
|
||||
grep -v "^#"|head -n 1|awk -F : '{print $2}')
|
||||
if [ -z ${iUSR} ] || [ -z ${iPWD} ];then
|
||||
echo "iUSR=$iUSR iPWD=$iPWD"
|
||||
echo "rsyncd.scrt format illegal, please check!";
|
||||
exit -1;
|
||||
fi
|
||||
|
||||
# produce password file
|
||||
echo "$iPWD" > ${ABSPATH}/.pass
|
||||
chmod 600 ${ABSPATH}/.pass
|
||||
[ ! -d $BACKUPPATH ] && mkdir -p ${BACKUPPATH}
|
||||
}
|
||||
|
||||
|
||||
function backup-module()
|
||||
{
|
||||
# print key information
|
||||
iModule=$1
|
||||
echo
|
||||
echo "---------------------------------------------------"
|
||||
echo "---- backup module ${iModule}@${SERVERIP} begin "
|
||||
echo "---- TIME=`date`----"
|
||||
echo "ABSPATH=${ABSPATH}"
|
||||
echo "BACKUPPATH=${BACKUPPATH}"
|
||||
echo "iUSR=$iUSR iPWD=$iPWD"
|
||||
echo "OPTIONS=${OPTIONS}"
|
||||
iModuleBackpath=${BACKUPPATH}/${iModule};
|
||||
[ ! -d ${iModuleBackpath} ] && mkdir -p ${iModuleBackpath}
|
||||
|
||||
# begin backup
|
||||
rsync ${OPTIONS} ${iUSR}@${SERVERIP}::${iModule} ${iModuleBackpath} \
|
||||
--password-file=${ABSPATH}/.pass
|
||||
if [ $? != 0 ];then
|
||||
echo "---- backup module ${iModule}@${SERVERIP} failed."
|
||||
else
|
||||
echo "---- backup module ${iModule}@${SERVERIP} succuess. "
|
||||
fi
|
||||
echo "---- TIME=`date`----"
|
||||
echo "---------------------------------------------------"
|
||||
echo
|
||||
}
|
||||
|
||||
function __main__()
|
||||
{
|
||||
get-user-pwd
|
||||
for md in $MODULE
|
||||
do
|
||||
backup-module $md
|
||||
done
|
||||
}
|
||||
|
||||
__main__
|
|
@ -0,0 +1,17 @@
|
|||
#[globale]
|
||||
strict modes = yes
|
||||
#rsync default port
|
||||
port = 873
|
||||
logfile = /var/log/rsyncd.log
|
||||
pidfile = /var/run/rsyncd.pid
|
||||
max connections = 4
|
||||
auth users = backup, user
|
||||
secrets file = /etc/rsyncd.scrt
|
||||
|
||||
#[modules] each path responding to a module
|
||||
[appbackup]
|
||||
path = /home/aborn/backup
|
||||
#hosts allow=9.4.122.24
|
||||
|
||||
[databackup]
|
||||
path = /home/data
|
|
@ -0,0 +1,2 @@
|
|||
backup:configurebackup@#$^&*()google
|
||||
user:passwordpassword
|
Loading…
Reference in New Issue